@pendo/agent 2.322.1 → 2.323.0

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.
package/dist/dom.esm.js CHANGED
@@ -7484,7 +7484,7 @@ function applyMatrix2dRect(matrix2d, rect) {
7484
7484
  return transformedRect;
7485
7485
  }
7486
7486
 
7487
- var VERSION = '2.322.1_';
7487
+ var VERSION = '2.323.0_';
7488
7488
 
7489
7489
  var decodeURIComponent = _.isFunction(window.decodeURIComponent) ? window.decodeURIComponent : _.identity;
7490
7490
 
@@ -7573,7 +7573,9 @@ var storageIsDisabled = function () {
7573
7573
  var getCookie = function (name) {
7574
7574
  var result;
7575
7575
  // eslint-disable-next-line no-cond-assign
7576
- return (result = new RegExp('(^|; )' + name + '=([^;]*)').exec(document.cookie)) ? decodeURIComponent(result[2]) : null;
7576
+ return (result = new RegExp('(^|; )' + name + '=([^;]*)').exec(document.cookie))
7577
+ ? decodeURIComponent(result[2])
7578
+ : null;
7577
7579
  };
7578
7580
  var setCookie = function (name, val, millisToExpire, isSecure) {
7579
7581
  if (ConfigReader.get('preventCookieRefresh')) {
@@ -7587,7 +7589,14 @@ var setCookie = function (name, val, millisToExpire, isSecure) {
7587
7589
  var canSecure = document.location.protocol === 'https:' || isSecure;
7588
7590
  var sameSite = canSecure ? 'None' : 'Strict';
7589
7591
  expireDate.setTime(expireDate.getTime() + cookieTTL);
7590
- var cookie = name + '=' + encodeURIComponent(val) + (millisToExpire ? ';expires=' + expireDate.toUTCString() : '') + '; path=/' + (canSecure ? ';secure' : '') + '; SameSite=' + sameSite;
7592
+ var cookie = name +
7593
+ '=' +
7594
+ encodeURIComponent(val) +
7595
+ (millisToExpire ? ';expires=' + expireDate.toUTCString() : '') +
7596
+ '; path=/' +
7597
+ (canSecure ? ';secure' : '') +
7598
+ '; SameSite=' +
7599
+ sameSite;
7591
7600
  document.cookie = cookie;
7592
7601
  };
7593
7602
  function hasCookieDomain() {
@@ -7674,9 +7683,9 @@ var StorageRegistry = /** @class */ (function () {
7674
7683
  * moving forward with new Agent refactoring and modularizing the code base.
7675
7684
  */
7676
7685
  /*
7677
- The majority of prior existing functionality still remains where it was. The
7678
- core Storage api is now in `agentStorage` with the original references still in place.
7679
- */
7686
+ The majority of prior existing functionality still remains where it was. The
7687
+ core Storage api is now in `agentStorage` with the original references still in place.
7688
+ */
7680
7689
  var agentStorage = (function () {
7681
7690
  var registry = new StorageRegistry();
7682
7691
  function wrapStorageWriteMethod(writeMethod, registryMethod) {
@@ -7708,18 +7717,18 @@ var agentStorage = (function () {
7708
7717
  return true;
7709
7718
  }
7710
7719
  catch (e) {
7711
- return e instanceof DOMException && (
7712
- // everything except Firefox
7713
- e.code === 22 ||
7714
- // Firefox
7715
- e.code === 1014 ||
7716
- // test name field too, because code might not be present
7720
+ return (e instanceof DOMException &&
7717
7721
  // everything except Firefox
7718
- e.name === 'QuotaExceededError' ||
7719
- // Firefox
7720
- e.name === 'NS_ERROR_DOM_QUOTA_REACHED') &&
7722
+ (e.code === 22 ||
7723
+ // Firefox
7724
+ e.code === 1014 ||
7725
+ // test name field too, because code might not be present
7726
+ // everything except Firefox
7727
+ e.name === 'QuotaExceededError' ||
7728
+ // Firefox
7729
+ e.name === 'NS_ERROR_DOM_QUOTA_REACHED') &&
7721
7730
  // acknowledge QuotaExceededError only if there's something already stored
7722
- (storage && storage.length !== 0);
7731
+ (storage && storage.length !== 0));
7723
7732
  }
7724
7733
  });
7725
7734
  function resetCache(mFn) {
@@ -7775,10 +7784,19 @@ var agentStorage = (function () {
7775
7784
  try {
7776
7785
  // JSON parsables: Numbers, Booleans, and Objects
7777
7786
  var obj = JSON.parse(value);
7778
- if (!obj.ttl) {
7787
+ // value is either a TimedStorageItem or just a PlainOldStorageItem
7788
+ // a TimedStorageItem will have both a ttl and value property
7789
+ var isTimedStorageItem = obj !== null && typeof obj === 'object' && 'ttl' in obj && 'value' in obj;
7790
+ if (!isTimedStorageItem) {
7779
7791
  return value;
7780
7792
  }
7781
- else if (obj.ttl < new Date().getTime()) {
7793
+ // ttl must always be an unsigned, non-zero number (a positive,
7794
+ // finite epoch-millis timestamp). Anything else (null, NaN, a
7795
+ // string, a negative number, 0, etc.) is treated as a missing /
7796
+ // invalid ttl and we fall through to returning the stored value
7797
+ // rather than discarding it as expired.
7798
+ var hasValidTtl = typeof obj.ttl === 'number' && isFinite(obj.ttl) && obj.ttl > 0;
7799
+ if (hasValidTtl && obj.ttl < new Date().getTime()) {
7782
7800
  return null;
7783
7801
  }
7784
7802
  return String(obj.value || obj);
@@ -7864,6 +7882,7 @@ var agentStorage = (function () {
7864
7882
  var wrappedPendoLocalStorage = _.extend({}, pendoLocalStorage);
7865
7883
  wrappedPendoLocalStorage.setItem = wrapStorageWriteMethod(wrappedPendoLocalStorage.setItem, 'hasLocal');
7866
7884
  return {
7885
+ /* API */
7867
7886
  read: read,
7868
7887
  write: wrapStorageWriteMethod(write, 'hasLocal'),
7869
7888
  clear: clear,