@nsshunt/stsobservability 1.0.76 → 1.0.78

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