@schibsted/account-sdk-browser 5.0.1-beta → 5.0.1-beta.2

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/identity.js CHANGED
@@ -1102,7 +1102,8 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
1102
1102
 
1103
1103
  var HAS_SESSION_CACHE_KEY = 'hasSession-cache';
1104
1104
  var SESSION_CALL_BLOCKED_CACHE_KEY = 'sessionCallBlocked-cache';
1105
- var SESSION_CALL_BLOCKED_TTL = 1000 * 30;
1105
+ var SESSION_CALL_BLOCKED_TTL = 1000 * 30; //set to 30s, the default period for a request timeout
1106
+
1106
1107
  var TAB_ID_KEY = 'tab-id-cache';
1107
1108
  var TAB_ID = Math.floor(Math.random() * 100000);
1108
1109
  var TAB_ID_TTL = 1000 * 60 * 60 * 24 * 30;
@@ -1153,8 +1154,12 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1153
1154
  _this._sessionInitiatedSent = false;
1154
1155
  _this.window = window;
1155
1156
  _this.clientId = clientId;
1156
- _this.sessionStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](_this.window && _this.window.sessionStorage);
1157
- _this.localStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](_this.window && _this.window.localStorage);
1157
+ _this.sessionStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](function () {
1158
+ return _this.window && _this.window.sessionStorage;
1159
+ });
1160
+ _this.localStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](function () {
1161
+ return _this.window && _this.window.localStorage;
1162
+ });
1158
1163
  _this.redirectUri = redirectUri;
1159
1164
  _this.env = env;
1160
1165
  _this.log = log;
@@ -1536,10 +1541,6 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1536
1541
  key: "hasSession",
1537
1542
  value: function hasSession() {
1538
1543
  var _this2 = this;
1539
- var isSessionCallBlocked = this._isSessionCallBlocked();
1540
- if (isSessionCallBlocked) {
1541
- return this._session;
1542
- }
1543
1544
  if (this._hasSessionInProgress) {
1544
1545
  return this._hasSessionInProgress;
1545
1546
  }
@@ -1575,19 +1576,26 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1575
1576
  }
1576
1577
  return _context.abrupt("return", _postProcess(cachedSession));
1577
1578
  case 4:
1579
+ if (!_this2._isSessionCallBlocked()) {
1580
+ _context.next = 6;
1581
+ break;
1582
+ }
1583
+ return _context.abrupt("return", _this2._session);
1584
+ case 6:
1578
1585
  sessionData = null;
1579
- _context.prev = 5;
1580
- _context.next = 8;
1586
+ _context.prev = 7;
1587
+ _this2._blockSessionCall();
1588
+ _context.next = 11;
1581
1589
  return _this2._sessionService.get('/v2/session', {
1582
1590
  tabId: _this2._tabId
1583
1591
  });
1584
- case 8:
1592
+ case 11:
1585
1593
  sessionData = _context.sent;
1586
- _context.next = 15;
1594
+ _context.next = 18;
1587
1595
  break;
1588
- case 11:
1589
- _context.prev = 11;
1590
- _context.t0 = _context["catch"](5);
1596
+ case 14:
1597
+ _context.prev = 14;
1598
+ _context.t0 = _context["catch"](7);
1591
1599
  if (_context.t0 && _context.t0.code === 400 && _this2._enableSessionCaching) {
1592
1600
  expiresIn = 1000 * (_context.t0.expiresIn || 300);
1593
1601
  _this2.sessionStorageCache.set(HAS_SESSION_CACHE_KEY, {
@@ -1595,34 +1603,33 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1595
1603
  }, expiresIn);
1596
1604
  }
1597
1605
  throw _context.t0;
1598
- case 15:
1606
+ case 18:
1599
1607
  if (!sessionData) {
1600
- _context.next = 22;
1608
+ _context.next = 24;
1601
1609
  break;
1602
1610
  }
1603
1611
  if (!_checkRedirectionNeed(sessionData)) {
1604
- _context.next = 21;
1612
+ _context.next = 23;
1605
1613
  break;
1606
1614
  }
1607
- _this2._blockSessionCall();
1608
- _context.next = 20;
1615
+ _context.next = 22;
1609
1616
  return _this2.callbackBeforeRedirect();
1610
- case 20:
1611
- return _context.abrupt("return", _this2._sessionService.makeUrl(sessionData.redirectURL, {
1617
+ case 22:
1618
+ _this2.window.location.href = _this2._sessionService.makeUrl(sessionData.redirectURL, {
1612
1619
  tabId: _this2._getTabId()
1613
- }));
1614
- case 21:
1620
+ });
1621
+ case 23:
1615
1622
  if (_this2._enableSessionCaching) {
1616
1623
  _expiresIn = 1000 * (sessionData.expiresIn || 300);
1617
1624
  _this2.sessionStorageCache.set(HAS_SESSION_CACHE_KEY, sessionData, _expiresIn);
1618
1625
  }
1619
- case 22:
1626
+ case 24:
1620
1627
  return _context.abrupt("return", _postProcess(sessionData));
1621
- case 23:
1628
+ case 25:
1622
1629
  case "end":
1623
1630
  return _context.stop();
1624
1631
  }
1625
- }, _callee, null, [[5, 11]]);
1632
+ }, _callee, null, [[7, 14]]);
1626
1633
  }));
1627
1634
  return function _getSession() {
1628
1635
  return _ref2.apply(this, arguments);
@@ -1630,15 +1637,13 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1630
1637
  }();
1631
1638
  this._hasSessionInProgress = _getSession().then(function (sessionData) {
1632
1639
  _this2._hasSessionInProgress = false;
1633
- if (Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["isUrl"])(sessionData)) {
1634
- return _this2.window.location.href = sessionData;
1635
- }
1636
1640
  return sessionData;
1637
1641
  }, function (err) {
1638
1642
  _this2.emit('error', err);
1639
1643
  _this2._hasSessionInProgress = false;
1640
1644
  throw new _SDKError_js__WEBPACK_IMPORTED_MODULE_63__["default"]('HasSession failed', err);
1641
1645
  });
1646
+ this._unblockSessionCallByTab();
1642
1647
  return this._hasSessionInProgress;
1643
1648
  }
1644
1649
 
@@ -11992,7 +11997,7 @@ __webpack_require__.r(__webpack_exports__);
11992
11997
 
11993
11998
 
11994
11999
 
11995
- var version = '5.0.1-beta';
12000
+ var version = '5.0.1-beta.2';
11996
12001
  /* harmony default export */ __webpack_exports__["default"] = (version);
11997
12002
 
11998
12003
  /***/ })