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