@schibsted/account-sdk-browser 5.0.1 → 5.1.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/es5/index.js CHANGED
@@ -1156,9 +1156,12 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1156
1156
  _this._sessionInitiatedSent = false;
1157
1157
  _this.window = window;
1158
1158
  _this.clientId = clientId;
1159
- _this.cache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](function () {
1159
+ _this.sessionStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](function () {
1160
1160
  return _this.window && _this.window.sessionStorage;
1161
1161
  });
1162
+ _this.localStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](function () {
1163
+ return _this.window && _this.window.localStorage;
1164
+ });
1162
1165
  _this.redirectUri = redirectUri;
1163
1166
  _this.env = env;
1164
1167
  _this.log = log;
@@ -1188,9 +1191,9 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1188
1191
  key: "_getTabId",
1189
1192
  value: function _getTabId() {
1190
1193
  if (this._enableSessionCaching) {
1191
- var tabId = this.cache.get(TAB_ID_KEY);
1194
+ var tabId = this.sessionStorageCache.get(TAB_ID_KEY);
1192
1195
  if (!tabId) {
1193
- this.cache.set(TAB_ID_KEY, TAB_ID, TAB_ID_TTL);
1196
+ this.sessionStorageCache.set(TAB_ID_KEY, TAB_ID, TAB_ID_TTL);
1194
1197
  return TAB_ID;
1195
1198
  }
1196
1199
  return tabId;
@@ -1206,9 +1209,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1206
1209
  }, {
1207
1210
  key: "_isSessionCallBlocked",
1208
1211
  value: function _isSessionCallBlocked() {
1209
- if (this._enableSessionCaching) {
1210
- return this.cache.get(SESSION_CALL_BLOCKED_CACHE_KEY);
1211
- }
1212
+ return this.localStorageCache.get(SESSION_CALL_BLOCKED_CACHE_KEY);
1212
1213
  }
1213
1214
 
1214
1215
  /**
@@ -1220,10 +1221,8 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1220
1221
  }, {
1221
1222
  key: "_blockSessionCall",
1222
1223
  value: function _blockSessionCall() {
1223
- if (this._enableSessionCaching) {
1224
- var SESSION_CALL_BLOCKED = true;
1225
- this.cache.set(SESSION_CALL_BLOCKED_CACHE_KEY, SESSION_CALL_BLOCKED, SESSION_CALL_BLOCKED_TTL);
1226
- }
1224
+ var SESSION_CALL_BLOCKED = true;
1225
+ this.localStorageCache.set(SESSION_CALL_BLOCKED_CACHE_KEY, SESSION_CALL_BLOCKED, SESSION_CALL_BLOCKED_TTL);
1227
1226
  }
1228
1227
 
1229
1228
  /**
@@ -1235,9 +1234,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1235
1234
  }, {
1236
1235
  key: "_unblockSessionCall",
1237
1236
  value: function _unblockSessionCall() {
1238
- if (this._enableSessionCaching) {
1239
- this.cache.delete(SESSION_CALL_BLOCKED_CACHE_KEY);
1240
- }
1237
+ this.localStorageCache.delete(SESSION_CALL_BLOCKED_CACHE_KEY);
1241
1238
  }
1242
1239
 
1243
1240
  /**
@@ -1581,7 +1578,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1581
1578
  break;
1582
1579
  }
1583
1580
  // Try to resolve from cache (it has a TTL)
1584
- cachedSession = _this2.cache.get(HAS_SESSION_CACHE_KEY);
1581
+ cachedSession = _this2.sessionStorageCache.get(HAS_SESSION_CACHE_KEY);
1585
1582
  if (!cachedSession) {
1586
1583
  _context.next = 4;
1587
1584
  break;
@@ -1603,7 +1600,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1603
1600
  _context.t0 = _context["catch"](5);
1604
1601
  if (_context.t0 && _context.t0.code === 400 && _this2._enableSessionCaching) {
1605
1602
  expiresIn = 1000 * (_context.t0.expiresIn || 300);
1606
- _this2.cache.set(HAS_SESSION_CACHE_KEY, {
1603
+ _this2.sessionStorageCache.set(HAS_SESSION_CACHE_KEY, {
1607
1604
  error: _context.t0
1608
1605
  }, expiresIn);
1609
1606
  }
@@ -1627,7 +1624,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1627
1624
  case 21:
1628
1625
  if (_this2._enableSessionCaching) {
1629
1626
  _expiresIn = 1000 * (sessionData.expiresIn || 300);
1630
- _this2.cache.set(HAS_SESSION_CACHE_KEY, sessionData, _expiresIn);
1627
+ _this2.sessionStorageCache.set(HAS_SESSION_CACHE_KEY, sessionData, _expiresIn);
1631
1628
  }
1632
1629
  case 22:
1633
1630
  return _context.abrupt("return", _postProcess(sessionData));
@@ -1698,7 +1695,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1698
1695
  }, {
1699
1696
  key: "clearCachedUserSession",
1700
1697
  value: function clearCachedUserSession() {
1701
- this.cache.delete(HAS_SESSION_CACHE_KEY);
1698
+ this.sessionStorageCache.delete(HAS_SESSION_CACHE_KEY);
1702
1699
  }
1703
1700
 
1704
1701
  /**
@@ -2093,7 +2090,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
2093
2090
  _ref4$prompt = _ref4.prompt,
2094
2091
  prompt = _ref4$prompt === void 0 ? 'select_account' : _ref4$prompt;
2095
2092
  this._closePopup();
2096
- this.cache.delete(HAS_SESSION_CACHE_KEY);
2093
+ this.sessionStorageCache.delete(HAS_SESSION_CACHE_KEY);
2097
2094
  var url = this.loginUrl({
2098
2095
  state: state,
2099
2096
  acrValues: acrValues,
@@ -2166,7 +2163,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
2166
2163
  key: "logout",
2167
2164
  value: function logout() {
2168
2165
  var redirectUri = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.redirectUri;
2169
- this.cache.delete(HAS_SESSION_CACHE_KEY);
2166
+ this.sessionStorageCache.delete(HAS_SESSION_CACHE_KEY);
2170
2167
  this._maybeClearVarnishCookie();
2171
2168
  this.emit('logout');
2172
2169
  this.window.location.href = this.logoutUrl(redirectUri);
@@ -2224,7 +2221,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
2224
2221
  maxAge = isNaN(arguments[7]) ? maxAge : arguments[7];
2225
2222
  }
2226
2223
  var isValidAcrValue = function isValidAcrValue(acrValue) {
2227
- return Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["isStrIn"])(acrValue, ['password', 'otp', 'sms', 'eid-no', 'eid-se', 'eid-fi', 'eid'], true);
2224
+ return Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["isStrIn"])(acrValue, ['password', 'otp', 'sms', 'eid-dk', 'eid-no', 'eid-se', 'eid-fi', 'eid'], true);
2228
2225
  };
2229
2226
  Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["assert"])(!acrValues || Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["isStrIn"])(acrValues, ['', 'otp-email'], true) || acrValues.split(' ').every(isValidAcrValue), "The acrValues parameter is not acceptable: ".concat(acrValues));
2230
2227
  Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["assert"])(Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["isUrl"])(redirectUri), "loginUrl(): redirectUri must be a valid url but is ".concat(redirectUri));
@@ -12008,7 +12005,7 @@ __webpack_require__.r(__webpack_exports__);
12008
12005
 
12009
12006
 
12010
12007
 
12011
- var version = '5.0.1';
12008
+ var version = '5.1.0';
12012
12009
  /* harmony default export */ __webpack_exports__["default"] = (version);
12013
12010
 
12014
12011
  /***/ }),