slnodejs 6.1.409 → 6.1.415

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.
@@ -27754,7 +27754,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
27754
27754
  this.instanceAddedForBsid[configuration.buildSessionId] = true;
27755
27755
  const browserAgent = agent_factory_1.AgentFactory.createBrowserAgent(this.window, this.featureDetection, configuration);
27756
27756
  const { enableOpenTelemetry } = configuration;
27757
- (0, events_bridge_1.registerEventsBridge)(this.logger, enableOpenTelemetry);
27757
+ (0, events_bridge_1.registerEventsBridge)(this.logger, enableOpenTelemetry, true, configuration.allowCORS);
27758
27758
  if (browserAgent) {
27759
27759
  browserAgent.start();
27760
27760
  this.instances.push(browserAgent);
@@ -28066,7 +28066,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28066
28066
  "use strict";
28067
28067
  Object.defineProperty(exports, "__esModule", { value: true });
28068
28068
  exports.SL_AGENT_TYPE = exports.SL_AGENT_VERSION = void 0;
28069
- exports.SL_AGENT_VERSION = '6.1.409';
28069
+ exports.SL_AGENT_VERSION = '6.1.415';
28070
28070
  exports.SL_AGENT_TYPE = 'browser';
28071
28071
  });
28072
28072
 
@@ -28664,7 +28664,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28664
28664
  if (v !== undefined) module.exports = v;
28665
28665
  }
28666
28666
  else if (typeof define === "function" && define.amd) {
28667
- define(["require", "exports", "@opentelemetry/instrumentation-fetch", "../utils", "../const"], factory);
28667
+ define(["require", "exports", "@opentelemetry/instrumentation-fetch", "../utils"], factory);
28668
28668
  }
28669
28669
  })(function (require, exports) {
28670
28670
  "use strict";
@@ -28672,7 +28672,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28672
28672
  exports.CustomFetchInstrumentation = exports.handleAddHeaders = void 0;
28673
28673
  const instrumentation_fetch_1 = require("@opentelemetry/instrumentation-fetch");
28674
28674
  const utils_1 = require("../utils");
28675
- const const_1 = require("../const");
28676
28675
  const setPropagationHeaders = (options, contextPropagationHeaders) => {
28677
28676
  for (const [key, value] of Object.entries(contextPropagationHeaders)) {
28678
28677
  if (value) {
@@ -28680,13 +28679,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28680
28679
  }
28681
28680
  }
28682
28681
  };
28683
- function handleAddHeaders(options, spanUrl) {
28684
- const origin = window.location.origin;
28685
- const startsWithOrigin = spanUrl === null || spanUrl === void 0 ? void 0 : spanUrl.startsWith(origin);
28686
- const isRelativeUrl = const_1.relativePathRegex.test(spanUrl);
28687
- if (!startsWithOrigin && !isRelativeUrl) {
28682
+ function handleAddHeaders(options, spanUrl, allowCORS) {
28683
+ const allowHeadersPropagation = (0, utils_1.shouldAddHeaders)(window.location.origin, spanUrl, allowCORS);
28684
+ if (!allowHeadersPropagation)
28688
28685
  return;
28689
- }
28690
28686
  const contextPropagationHeaders = Object.assign(Object.assign({}, (0, utils_1.constructBaggageHeader)()), (0, utils_1.constructContextHeaders)());
28691
28687
  if (options instanceof Request && contextPropagationHeaders) {
28692
28688
  setPropagationHeaders(options, contextPropagationHeaders);
@@ -28707,20 +28703,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28707
28703
  class CustomFetchInstrumentation extends instrumentation_fetch_1.FetchInstrumentation {
28708
28704
  constructor(config) {
28709
28705
  super(config);
28710
- this['_addHeaders'] = (options, spanUrl) => handleAddHeaders(options, spanUrl);
28706
+ this['_addHeaders'] = (options, spanUrl) => handleAddHeaders(options, spanUrl, config === null || config === void 0 ? void 0 : config.allowCORS);
28711
28707
  }
28712
28708
  }
28713
28709
  exports.CustomFetchInstrumentation = CustomFetchInstrumentation;
28714
28710
  });
28715
28711
 
28716
- },{"../const":237,"../utils":244,"@opentelemetry/instrumentation-fetch":89}],241:[function(require,module,exports){
28712
+ },{"../utils":244,"@opentelemetry/instrumentation-fetch":89}],241:[function(require,module,exports){
28717
28713
  (function (factory) {
28718
28714
  if (typeof module === "object" && typeof module.exports === "object") {
28719
28715
  var v = factory(require, exports);
28720
28716
  if (v !== undefined) module.exports = v;
28721
28717
  }
28722
28718
  else if (typeof define === "function" && define.amd) {
28723
- define(["require", "exports", "@opentelemetry/instrumentation-xml-http-request", "../utils", "../const"], factory);
28719
+ define(["require", "exports", "@opentelemetry/instrumentation-xml-http-request", "../utils"], factory);
28724
28720
  }
28725
28721
  })(function (require, exports) {
28726
28722
  "use strict";
@@ -28728,14 +28724,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28728
28724
  exports.CustomXMLHttpRequestInstrumentation = exports.handleAddHeaders = void 0;
28729
28725
  const instrumentation_xml_http_request_1 = require("@opentelemetry/instrumentation-xml-http-request");
28730
28726
  const utils_1 = require("../utils");
28731
- const const_1 = require("../const");
28732
- function handleAddHeaders(xhr, spanUrl) {
28733
- const origin = window.location.origin;
28734
- const startsWithOrigin = spanUrl === null || spanUrl === void 0 ? void 0 : spanUrl.startsWith(origin);
28735
- const isRelativeUrl = const_1.relativePathRegex.test(spanUrl);
28736
- if (!startsWithOrigin && !isRelativeUrl) {
28727
+ function handleAddHeaders(xhr, spanUrl, allowCORS) {
28728
+ const allowHeadersPropagation = (0, utils_1.shouldAddHeaders)(window.location.origin, spanUrl, allowCORS);
28729
+ if (!allowHeadersPropagation)
28737
28730
  return;
28738
- }
28739
28731
  const headers = Object.assign(Object.assign({}, (0, utils_1.constructBaggageHeader)()), (0, utils_1.constructContextHeaders)());
28740
28732
  Object.keys(headers).forEach((headerKey) => {
28741
28733
  xhr.setRequestHeader(headerKey, headers[headerKey]);
@@ -28745,13 +28737,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28745
28737
  class CustomXMLHttpRequestInstrumentation extends instrumentation_xml_http_request_1.XMLHttpRequestInstrumentation {
28746
28738
  constructor(config) {
28747
28739
  super(config);
28748
- this['_addHeaders'] = (xhr, spanUrl) => handleAddHeaders(xhr, spanUrl);
28740
+ this['_addHeaders'] = (xhr, spanUrl) => handleAddHeaders(xhr, spanUrl, config === null || config === void 0 ? void 0 : config.allowCORS);
28749
28741
  }
28750
28742
  }
28751
28743
  exports.CustomXMLHttpRequestInstrumentation = CustomXMLHttpRequestInstrumentation;
28752
28744
  });
28753
28745
 
28754
- },{"../const":237,"../utils":244,"@opentelemetry/instrumentation-xml-http-request":93}],242:[function(require,module,exports){
28746
+ },{"../utils":244,"@opentelemetry/instrumentation-xml-http-request":93}],242:[function(require,module,exports){
28755
28747
  (function (factory) {
28756
28748
  if (typeof module === "object" && typeof module.exports === "object") {
28757
28749
  var v = factory(require, exports);
@@ -28767,7 +28759,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28767
28759
  const otel_1 = require("./otel");
28768
28760
  const events_1 = require("./events");
28769
28761
  const const_1 = require("./const");
28770
- const registerEventsBridge = (logger, enableOpenTelemetry, sendCockpitEvents = true) => {
28762
+ const registerEventsBridge = (logger, enableOpenTelemetry, sendCockpitEvents = true, allowCORS) => {
28771
28763
  var _a, _b, _c, _d;
28772
28764
  const eventsBridgeRegistered = (_b = (_a = window.$Sealights) === null || _a === void 0 ? void 0 : _a.eventsBridge) === null || _b === void 0 ? void 0 : _b.loaded;
28773
28765
  const otelRegistered = (_d = (_c = window.$Sealights) === null || _c === void 0 ? void 0 : _c.eventsBridge) === null || _d === void 0 ? void 0 : _d.otel;
@@ -28775,7 +28767,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28775
28767
  (0, events_1.registerEvents)(logger, enableOpenTelemetry, sendCockpitEvents);
28776
28768
  }
28777
28769
  if (enableOpenTelemetry && !otelRegistered) {
28778
- (0, otel_1.registerOpenTelemetry)(logger);
28770
+ (0, otel_1.registerOpenTelemetry)(logger, allowCORS);
28779
28771
  }
28780
28772
  const event = new Event(const_1.EVENTS.READY_EVENTS_BRIDGE);
28781
28773
  window.dispatchEvent(event);
@@ -28800,12 +28792,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28800
28792
  const CustomFetchInstrumentation_1 = require("./implementations/CustomFetchInstrumentation");
28801
28793
  const CustomXMLHttpRequestInstrumentation_1 = require("./implementations/CustomXMLHttpRequestInstrumentation");
28802
28794
  const cockpit_notifier_1 = require("../../../common/agent-events/cockpit-notifier");
28803
- const registerOpenTelemetry = (logger) => {
28795
+ const registerOpenTelemetry = (logger, allowCORS) => {
28804
28796
  try {
28805
28797
  (0, instrumentation_1.registerInstrumentations)({
28806
28798
  instrumentations: [
28807
- new CustomFetchInstrumentation_1.CustomFetchInstrumentation(),
28808
- new CustomXMLHttpRequestInstrumentation_1.CustomXMLHttpRequestInstrumentation(),
28799
+ new CustomFetchInstrumentation_1.CustomFetchInstrumentation({ allowCORS }),
28800
+ new CustomXMLHttpRequestInstrumentation_1.CustomXMLHttpRequestInstrumentation({ allowCORS }),
28809
28801
  ],
28810
28802
  });
28811
28803
  }
@@ -28830,7 +28822,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28830
28822
  })(function (require, exports) {
28831
28823
  "use strict";
28832
28824
  Object.defineProperty(exports, "__esModule", { value: true });
28833
- exports.sendAckEvent = exports.checkIsDiagnosisBaggage = exports.constructContextHeaders = exports.constructBaggageHeader = exports.mapHeaderValuesToString = void 0;
28825
+ exports.shouldAddHeaders = exports.sendAckEvent = exports.checkIsDiagnosisBaggage = exports.constructContextHeaders = exports.constructBaggageHeader = exports.mapHeaderValuesToString = void 0;
28834
28826
  const const_1 = require("./const");
28835
28827
  const SlConst = require("./const");
28836
28828
  const mapHeaderValuesToString = (headerValues) => {
@@ -28884,6 +28876,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28884
28876
  }));
28885
28877
  };
28886
28878
  exports.sendAckEvent = sendAckEvent;
28879
+ const shouldAddHeaders = (origin, spanUrl, allowCORS) => {
28880
+ if ((allowCORS === null || allowCORS === void 0 ? void 0 : allowCORS.trim()) === '*')
28881
+ return true;
28882
+ const isRelativeUrl = const_1.relativePathRegex.test(spanUrl);
28883
+ if (isRelativeUrl) {
28884
+ spanUrl = `${origin}${spanUrl.startsWith('/') ? '' : '/'}${spanUrl}`;
28885
+ }
28886
+ const allowCORSArray = !(allowCORS === null || allowCORS === void 0 ? void 0 : allowCORS.length)
28887
+ ? [origin]
28888
+ : allowCORS === null || allowCORS === void 0 ? void 0 : allowCORS.split(',');
28889
+ return allowCORSArray.some((propagationOrigin) => spanUrl === null || spanUrl === void 0 ? void 0 : spanUrl.startsWith(propagationOrigin.trim()));
28890
+ };
28891
+ exports.shouldAddHeaders = shouldAddHeaders;
28887
28892
  });
28888
28893
 
28889
28894
  },{"./const":237}],245:[function(require,module,exports){