@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/global.js CHANGED
@@ -1985,7 +1985,8 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
1985
1985
 
1986
1986
  var HAS_SESSION_CACHE_KEY = 'hasSession-cache';
1987
1987
  var SESSION_CALL_BLOCKED_CACHE_KEY = 'sessionCallBlocked-cache';
1988
- var SESSION_CALL_BLOCKED_TTL = 1000 * 30;
1988
+ var SESSION_CALL_BLOCKED_TTL = 1000 * 30; //set to 30s, the default period for a request timeout
1989
+
1989
1990
  var TAB_ID_KEY = 'tab-id-cache';
1990
1991
  var TAB_ID = Math.floor(Math.random() * 100000);
1991
1992
  var TAB_ID_TTL = 1000 * 60 * 60 * 24 * 30;
@@ -2036,8 +2037,12 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
2036
2037
  _this._sessionInitiatedSent = false;
2037
2038
  _this.window = window;
2038
2039
  _this.clientId = clientId;
2039
- _this.sessionStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](_this.window && _this.window.sessionStorage);
2040
- _this.localStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](_this.window && _this.window.localStorage);
2040
+ _this.sessionStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](function () {
2041
+ return _this.window && _this.window.sessionStorage;
2042
+ });
2043
+ _this.localStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](function () {
2044
+ return _this.window && _this.window.localStorage;
2045
+ });
2041
2046
  _this.redirectUri = redirectUri;
2042
2047
  _this.env = env;
2043
2048
  _this.log = log;
@@ -2419,10 +2424,6 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
2419
2424
  key: "hasSession",
2420
2425
  value: function hasSession() {
2421
2426
  var _this2 = this;
2422
- var isSessionCallBlocked = this._isSessionCallBlocked();
2423
- if (isSessionCallBlocked) {
2424
- return this._session;
2425
- }
2426
2427
  if (this._hasSessionInProgress) {
2427
2428
  return this._hasSessionInProgress;
2428
2429
  }
@@ -2458,19 +2459,26 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
2458
2459
  }
2459
2460
  return _context.abrupt("return", _postProcess(cachedSession));
2460
2461
  case 4:
2462
+ if (!_this2._isSessionCallBlocked()) {
2463
+ _context.next = 6;
2464
+ break;
2465
+ }
2466
+ return _context.abrupt("return", _this2._session);
2467
+ case 6:
2461
2468
  sessionData = null;
2462
- _context.prev = 5;
2463
- _context.next = 8;
2469
+ _context.prev = 7;
2470
+ _this2._blockSessionCall();
2471
+ _context.next = 11;
2464
2472
  return _this2._sessionService.get('/v2/session', {
2465
2473
  tabId: _this2._tabId
2466
2474
  });
2467
- case 8:
2475
+ case 11:
2468
2476
  sessionData = _context.sent;
2469
- _context.next = 15;
2477
+ _context.next = 18;
2470
2478
  break;
2471
- case 11:
2472
- _context.prev = 11;
2473
- _context.t0 = _context["catch"](5);
2479
+ case 14:
2480
+ _context.prev = 14;
2481
+ _context.t0 = _context["catch"](7);
2474
2482
  if (_context.t0 && _context.t0.code === 400 && _this2._enableSessionCaching) {
2475
2483
  expiresIn = 1000 * (_context.t0.expiresIn || 300);
2476
2484
  _this2.sessionStorageCache.set(HAS_SESSION_CACHE_KEY, {
@@ -2478,34 +2486,33 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
2478
2486
  }, expiresIn);
2479
2487
  }
2480
2488
  throw _context.t0;
2481
- case 15:
2489
+ case 18:
2482
2490
  if (!sessionData) {
2483
- _context.next = 22;
2491
+ _context.next = 24;
2484
2492
  break;
2485
2493
  }
2486
2494
  if (!_checkRedirectionNeed(sessionData)) {
2487
- _context.next = 21;
2495
+ _context.next = 23;
2488
2496
  break;
2489
2497
  }
2490
- _this2._blockSessionCall();
2491
- _context.next = 20;
2498
+ _context.next = 22;
2492
2499
  return _this2.callbackBeforeRedirect();
2493
- case 20:
2494
- return _context.abrupt("return", _this2._sessionService.makeUrl(sessionData.redirectURL, {
2500
+ case 22:
2501
+ _this2.window.location.href = _this2._sessionService.makeUrl(sessionData.redirectURL, {
2495
2502
  tabId: _this2._getTabId()
2496
- }));
2497
- case 21:
2503
+ });
2504
+ case 23:
2498
2505
  if (_this2._enableSessionCaching) {
2499
2506
  _expiresIn = 1000 * (sessionData.expiresIn || 300);
2500
2507
  _this2.sessionStorageCache.set(HAS_SESSION_CACHE_KEY, sessionData, _expiresIn);
2501
2508
  }
2502
- case 22:
2509
+ case 24:
2503
2510
  return _context.abrupt("return", _postProcess(sessionData));
2504
- case 23:
2511
+ case 25:
2505
2512
  case "end":
2506
2513
  return _context.stop();
2507
2514
  }
2508
- }, _callee, null, [[5, 11]]);
2515
+ }, _callee, null, [[7, 14]]);
2509
2516
  }));
2510
2517
  return function _getSession() {
2511
2518
  return _ref2.apply(this, arguments);
@@ -2513,15 +2520,13 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
2513
2520
  }();
2514
2521
  this._hasSessionInProgress = _getSession().then(function (sessionData) {
2515
2522
  _this2._hasSessionInProgress = false;
2516
- if (Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["isUrl"])(sessionData)) {
2517
- return _this2.window.location.href = sessionData;
2518
- }
2519
2523
  return sessionData;
2520
2524
  }, function (err) {
2521
2525
  _this2.emit('error', err);
2522
2526
  _this2._hasSessionInProgress = false;
2523
2527
  throw new _SDKError_js__WEBPACK_IMPORTED_MODULE_63__["default"]('HasSession failed', err);
2524
2528
  });
2529
+ this._unblockSessionCallByTab();
2525
2530
  return this._hasSessionInProgress;
2526
2531
  }
2527
2532
 
@@ -12026,7 +12031,7 @@ __webpack_require__.r(__webpack_exports__);
12026
12031
 
12027
12032
 
12028
12033
 
12029
- var version = '5.0.1-beta';
12034
+ var version = '5.0.1-beta.2';
12030
12035
  /* harmony default export */ __webpack_exports__["default"] = (version);
12031
12036
 
12032
12037
  /***/ }),