@nsshunt/stsobservability 1.0.76 → 1.0.77

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.
@@ -4923,7 +4923,7 @@ var __privateWrapper2 = (obj, member, setter, getter) => ({
4923
4923
  return __privateGet2(obj, member, getter);
4924
4924
  }
4925
4925
  });
4926
- var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions, _url, _method, _headers, _data, _agentManager, _timeout;
4926
+ var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions, _url, _method, _headers, _data, _agentManager, _timeout, _withCredentials;
4927
4927
  var ansiStyles$1 = { exports: {} };
4928
4928
  var colorName;
4929
4929
  var hasRequiredColorName;
@@ -6701,18 +6701,55 @@ class STSAxiosConfig {
6701
6701
  __privateAdd2(this, _data);
6702
6702
  __privateAdd2(this, _agentManager);
6703
6703
  __privateAdd2(this, _timeout);
6704
+ __privateAdd2(this, _withCredentials);
6704
6705
  __privateSet2(this, _url, url);
6705
6706
  __privateSet2(this, _method, method);
6706
- __privateSet2(this, _headers, headers);
6707
+ if (headers !== void 0) {
6708
+ __privateSet2(this, _headers, headers);
6709
+ }
6707
6710
  if (timeout !== void 0) {
6708
6711
  __privateSet2(this, _timeout, timeout);
6709
6712
  }
6710
6713
  }
6714
+ withCookies(cookies) {
6715
+ if (!__privateGet2(this, _headers)) {
6716
+ __privateSet2(this, _headers, {});
6717
+ }
6718
+ __privateGet2(this, _headers)["Cookie"] = cookies.join("; ");
6719
+ return this;
6720
+ }
6711
6721
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6712
6722
  withData(data) {
6713
6723
  __privateSet2(this, _data, data);
6714
6724
  return this;
6715
6725
  }
6726
+ // 'Content-Type': 'application/json'
6727
+ withAuthHeaders(accesssToken, stsUserId) {
6728
+ if (!__privateGet2(this, _headers)) {
6729
+ __privateSet2(this, _headers, {});
6730
+ }
6731
+ __privateGet2(this, _headers)["Content-Type"] = "application/json";
6732
+ __privateGet2(this, _headers)["Authorization"] = "Bearer " + accesssToken;
6733
+ if (stsUserId) {
6734
+ __privateGet2(this, _headers)["x-sts_user_id"] = stsUserId;
6735
+ }
6736
+ return this;
6737
+ }
6738
+ withHeaders(headers) {
6739
+ __privateSet2(this, _headers, headers);
6740
+ return this;
6741
+ }
6742
+ withDefaultHeaders() {
6743
+ if (!__privateGet2(this, _headers)) {
6744
+ __privateSet2(this, _headers, {});
6745
+ }
6746
+ __privateGet2(this, _headers)["Content-Type"] = "application/json";
6747
+ return this;
6748
+ }
6749
+ withCredentials() {
6750
+ __privateSet2(this, _withCredentials, true);
6751
+ return this;
6752
+ }
6716
6753
  withTimeout(timeout) {
6717
6754
  __privateSet2(this, _timeout, timeout);
6718
6755
  return this;
@@ -6724,9 +6761,11 @@ class STSAxiosConfig {
6724
6761
  get config() {
6725
6762
  const retVal = {
6726
6763
  url: __privateGet2(this, _url),
6727
- method: __privateGet2(this, _method),
6728
- headers: __privateGet2(this, _headers)
6764
+ method: __privateGet2(this, _method)
6729
6765
  };
6766
+ if (__privateGet2(this, _headers)) {
6767
+ retVal.headers = __privateGet2(this, _headers);
6768
+ }
6730
6769
  if (__privateGet2(this, _agentManager) !== void 0) {
6731
6770
  if (__privateGet2(this, _agentManager).IsHttps(__privateGet2(this, _url))) {
6732
6771
  retVal.httpsAgent = __privateGet2(this, _agentManager).GetAgent(__privateGet2(this, _url));
@@ -6740,6 +6779,9 @@ class STSAxiosConfig {
6740
6779
  if (__privateGet2(this, _timeout) !== void 0) {
6741
6780
  retVal.timeout = __privateGet2(this, _timeout);
6742
6781
  }
6782
+ if (__privateGet2(this, _withCredentials) !== void 0 && __privateGet2(this, _withCredentials) === true) {
6783
+ retVal.withCredentials = true;
6784
+ }
6743
6785
  return retVal;
6744
6786
  }
6745
6787
  }
@@ -6749,6 +6791,7 @@ _headers = /* @__PURE__ */ new WeakMap();
6749
6791
  _data = /* @__PURE__ */ new WeakMap();
6750
6792
  _agentManager = /* @__PURE__ */ new WeakMap();
6751
6793
  _timeout = /* @__PURE__ */ new WeakMap();
6794
+ _withCredentials = /* @__PURE__ */ new WeakMap();
6752
6795
  class PublishTransportRESTServer extends STSOptionsBase {
6753
6796
  constructor(options) {
6754
6797
  super(options);
@@ -6766,14 +6809,17 @@ class PublishTransportRESTServer extends STSOptionsBase {
6766
6809
  if (this.options.socketPath) {
6767
6810
  retVal = await axios({
6768
6811
  method: "post",
6769
- //data: payload,
6770
6812
  data: Buffer.from(encodedData),
6771
6813
  headers,
6772
6814
  socketPath: this.options.socketPath
6773
6815
  });
6774
6816
  } else {
6775
- if (isNode && __privateGet(this, _agentManager2)) {
6776
- retVal = await axios(new STSAxiosConfig(this.options.url, "post", headers).withData(Buffer.from(encodedData)).withAgentManager(__privateGet(this, _agentManager2)).config);
6817
+ if (isNode) {
6818
+ if (__privateGet(this, _agentManager2)) {
6819
+ retVal = await axios(new STSAxiosConfig(this.options.url, "post", headers).withData(Buffer.from(encodedData)).withAgentManager(__privateGet(this, _agentManager2)).config);
6820
+ } else {
6821
+ retVal = await axios(new STSAxiosConfig(this.options.url, "post", headers).withData(Buffer.from(encodedData)).config);
6822
+ }
6777
6823
  } else {
6778
6824
  const blob = new Blob([encodedData], { type: "application/octet-stream" });
6779
6825
  retVal = await axios(new STSAxiosConfig(this.options.url, "post", headers).withData(blob).config);
@@ -7808,20 +7854,13 @@ InvokeRESTAPI_fn = async function(subscription) {
7808
7854
  }
7809
7855
  if (url.localeCompare("") !== 0) {
7810
7856
  const endPointUrl = `${__privateGet(this, _options3).urlBase}${url}`;
7811
- const headers = {
7812
- "Content-Type": "application/json"
7813
- };
7814
7857
  let retVal;
7815
7858
  const start = performance.now();
7816
7859
  try {
7817
7860
  if (isNode && __privateGet(this, _agentManager3)) {
7818
- retVal = await axios(new STSAxiosConfig(endPointUrl, "get", headers).withAgentManager(__privateGet(this, _agentManager3)).config);
7861
+ retVal = await axios(new STSAxiosConfig(endPointUrl, "get").withDefaultHeaders().withAgentManager(__privateGet(this, _agentManager3)).config);
7819
7862
  } else {
7820
- retVal = await axios({
7821
- url: endPointUrl,
7822
- method: "get",
7823
- headers
7824
- });
7863
+ retVal = await axios(new STSAxiosConfig(endPointUrl, "get").withDefaultHeaders().config);
7825
7864
  }
7826
7865
  const end = performance.now();
7827
7866
  const diff = end - start;