@schibsted/account-sdk-browser 5.0.1-beta.3 → 5.0.1-beta.4

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/es5/index.js CHANGED
@@ -1206,14 +1206,15 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1206
1206
  }
1207
1207
 
1208
1208
  /**
1209
- * Checks if calling GET session is blocked
1209
+ * Checks if calling GET session is blocked by a cache storage
1210
1210
  * @private
1211
- * @returns {number|null}
1211
+ * @param {Cache} cache - cache to check
1212
+ * @returns {string|null}
1212
1213
  */
1213
1214
  }, {
1214
1215
  key: "_isSessionCallBlocked",
1215
- value: function _isSessionCallBlocked() {
1216
- return this.localStorageCache.get(SESSION_CALL_BLOCKED_CACHE_KEY);
1216
+ value: function _isSessionCallBlocked(cache) {
1217
+ return cache.get(SESSION_CALL_BLOCKED_CACHE_KEY);
1217
1218
  }
1218
1219
 
1219
1220
  /**
@@ -1224,6 +1225,10 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1224
1225
  }, {
1225
1226
  key: "_blockSessionCall",
1226
1227
  value: function _blockSessionCall() {
1228
+ // session storage block protects against single tab, multiple identity instance concurrency
1229
+ this.sessionStorageCache.set(SESSION_CALL_BLOCKED_CACHE_KEY, this._tabId, SESSION_CALL_BLOCKED_TTL);
1230
+
1231
+ // local storage block protects against cross-tab concurrency
1227
1232
  this.localStorageCache.set(SESSION_CALL_BLOCKED_CACHE_KEY, this._tabId, SESSION_CALL_BLOCKED_TTL);
1228
1233
  }
1229
1234
 
@@ -1235,9 +1240,10 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1235
1240
  }, {
1236
1241
  key: "_unblockSessionCallByTab",
1237
1242
  value: function _unblockSessionCallByTab() {
1238
- if (this._isSessionCallBlocked() === this._tabId) {
1243
+ if (this._isSessionCallBlocked(this.localStorageCache) === this._tabId) {
1239
1244
  this.localStorageCache.delete(SESSION_CALL_BLOCKED_CACHE_KEY);
1240
1245
  }
1246
+ this.sessionStorageCache.delete(SESSION_CALL_BLOCKED_CACHE_KEY);
1241
1247
  }
1242
1248
 
1243
1249
  /**
@@ -1579,8 +1585,8 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1579
1585
  while (1) switch (_context.prev = _context.next) {
1580
1586
  case 0:
1581
1587
  _context.prev = 0;
1582
- // Blocking future calls to session-service. This lock is removed after the response is processed
1583
- // to account for redirection that can happen towards session-service too
1588
+ /* Blocking future calls to session-service. This lock is removed after the response is processed
1589
+ to account for redirection that can happen towards session-service too */
1584
1590
  _this2._blockSessionCall();
1585
1591
  _context.next = 4;
1586
1592
  return _this2._sessionService.get('/v2/session', {
@@ -1662,7 +1668,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1662
1668
  }
1663
1669
  return _context3.abrupt("return", _postProcess(cachedSession));
1664
1670
  case 4:
1665
- if (!_this2._isSessionCallBlocked()) {
1671
+ if (!(_this2._isSessionCallBlocked(_this2.sessionStorageCache) || _this2._isSessionCallBlocked(_this2.localStorageCache))) {
1666
1672
  _context3.next = 13;
1667
1673
  break;
1668
1674
  }
@@ -1719,9 +1725,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1719
1725
  randomWaitTime = MIN_SESSION_CALL_WAIT_TIME + randomWaitingStep * 100;
1720
1726
  _context4.next = 5;
1721
1727
  return new Promise(function (resolve) {
1722
- setTimeout(function () {
1723
- return resolve();
1724
- }, randomWaitTime);
1728
+ return setTimeout(resolve, randomWaitTime);
1725
1729
  });
1726
1730
  case 5:
1727
1731
  _context4.next = 7;
@@ -2021,9 +2025,9 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
2021
2025
  throw new _SDKError_js__WEBPACK_IMPORTED_MODULE_63__["default"]('externalParty cannot be empty');
2022
2026
  case 9:
2023
2027
  _toHexDigest = function _toHexDigest(hashBuffer) {
2024
- // convert buffer to byte array
2028
+ // Convert buffer to byte array
2025
2029
  var hashArray = Array.from(new Uint8Array(hashBuffer));
2026
- // convert bytes to hex string
2030
+ // Convert bytes to hex string
2027
2031
  return hashArray.map(function (b) {
2028
2032
  return b.toString(16).padStart(2, '0');
2029
2033
  }).join('');
@@ -2354,7 +2358,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
2354
2358
  _ref9$prompt = _ref9.prompt,
2355
2359
  prompt = _ref9$prompt === void 0 ? 'select_account' : _ref9$prompt;
2356
2360
  if (_typeof(arguments[0]) !== 'object') {
2357
- // backward compatibility
2361
+ // Backward compatibility
2358
2362
  state = arguments[0];
2359
2363
  acrValues = arguments[1];
2360
2364
  scope = arguments[2] || scope;
@@ -12146,7 +12150,7 @@ __webpack_require__.r(__webpack_exports__);
12146
12150
 
12147
12151
 
12148
12152
 
12149
- var version = '5.0.1-beta.3';
12153
+ var version = '5.0.1-beta.4';
12150
12154
  /* harmony default export */ __webpack_exports__["default"] = (version);
12151
12155
 
12152
12156
  /***/ }),