@schibsted/account-sdk-browser 4.8.6-beta.2 → 4.8.7-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
@@ -90,7 +90,7 @@ module.exports =
90
90
  /***/ (function(module, exports, __webpack_require__) {
91
91
 
92
92
  "use strict";
93
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
93
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
94
94
  * See LICENSE.md in the project root.
95
95
  */
96
96
 
@@ -883,7 +883,7 @@ __webpack_require__.r(__webpack_exports__);
883
883
  /* harmony import */ var _SDKError_js__WEBPACK_IMPORTED_MODULE_63__ = __webpack_require__(189);
884
884
  /* harmony import */ var _spidTalk_js__WEBPACK_IMPORTED_MODULE_64__ = __webpack_require__(217);
885
885
  /* harmony import */ var _version_js__WEBPACK_IMPORTED_MODULE_65__ = __webpack_require__(218);
886
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
886
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
887
887
  * See LICENSE.md in the project root.
888
888
  */
889
889
 
@@ -1120,6 +1120,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1120
1120
  * @param {function} [options.log] - A function that receives debug log information. If not set,
1121
1121
  * no logging will be done
1122
1122
  * @param {object} [options.window] - window object
1123
+ * @param {function} [options.callbackBeforeRedirect] - callback triggered before session refresh redirect happen
1123
1124
  * @throws {SDKError} - If any of options are invalid
1124
1125
  */
1125
1126
  function Identity(_ref) {
@@ -1131,7 +1132,9 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1131
1132
  env = _ref$env === void 0 ? 'PRE' : _ref$env,
1132
1133
  log = _ref.log,
1133
1134
  _ref$window = _ref.window,
1134
- window = _ref$window === void 0 ? globalWindow() : _ref$window;
1135
+ window = _ref$window === void 0 ? globalWindow() : _ref$window,
1136
+ _ref$callbackBeforeRe = _ref.callbackBeforeRedirect,
1137
+ callbackBeforeRedirect = _ref$callbackBeforeRe === void 0 ? function () {} : _ref$callbackBeforeRe;
1135
1138
  _classCallCheck(this, Identity);
1136
1139
  _this = _super.call(this);
1137
1140
  Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["assert"])(Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["isNonEmptyString"])(clientId), 'clientId parameter is required');
@@ -1148,6 +1151,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1148
1151
  _this.redirectUri = redirectUri;
1149
1152
  _this.env = env;
1150
1153
  _this.log = log;
1154
+ _this.callbackBeforeRedirect = callbackBeforeRedirect;
1151
1155
  _this._sessionDomain = sessionDomain;
1152
1156
 
1153
1157
  // Internal hack: set to false to always refresh from hassession
@@ -1367,10 +1371,8 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1367
1371
  if (Number.isInteger(options)) {
1368
1372
  expiresIn = options;
1369
1373
  } else if (_typeof(options) == 'object') {
1370
- var _options$expiresIn = options.expiresIn;
1371
- expiresIn = _options$expiresIn === void 0 ? expiresIn : _options$expiresIn;
1372
- var _options$domain = options.domain;
1373
- domain = _options$domain === void 0 ? domain : _options$domain;
1374
+ expiresIn = options.expiresIn || expiresIn;
1375
+ domain = options.domain || domain;
1374
1376
  }
1375
1377
  Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["assert"])(Number.isInteger(expiresIn), "'expiresIn' must be an integer");
1376
1378
  Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["assert"])(expiresIn >= 0, "'expiresIn' cannot be negative");
@@ -1427,7 +1429,8 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1427
1429
  }, {
1428
1430
  key: "_clearVarnishCookie",
1429
1431
  value: function _clearVarnishCookie() {
1430
- var domain = this.varnishCookieDomain || (this._session && typeof this._session.baseDomain === 'string' ? this._session.baseDomain : document.domain) || '';
1432
+ var baseDomain = this._session && typeof this._session.baseDomain === 'string' ? this._session.baseDomain : document.domain;
1433
+ var domain = this.varnishCookieDomain || baseDomain || '';
1431
1434
  document.cookie = "SP_ID=nothing; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=.".concat(domain);
1432
1435
  }
1433
1436
 
@@ -1488,12 +1491,11 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1488
1491
  var _checkRedirectionNeed = function _checkRedirectionNeed() {
1489
1492
  var sessionData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1490
1493
  var sessionDataKeys = Object.keys(sessionData);
1491
- var isRedirectNeeded = sessionDataKeys.length === 1 && sessionDataKeys[0] === 'redirectURL';
1492
- return isRedirectNeeded;
1494
+ return sessionDataKeys.length === 1 && sessionDataKeys[0] === 'redirectURL';
1493
1495
  };
1494
1496
  var _getSession = /*#__PURE__*/function () {
1495
1497
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1496
- var cachedSession, sessionData, expiresIn, client_sdrn, redirectBackUrl, params, _expiresIn;
1498
+ var cachedSession, sessionData, expiresIn, _expiresIn;
1497
1499
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1498
1500
  while (1) switch (_context.prev = _context.next) {
1499
1501
  case 0:
@@ -1512,7 +1514,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1512
1514
  sessionData = null;
1513
1515
  _context.prev = 5;
1514
1516
  _context.next = 8;
1515
- return _this2._sessionService.get('/session');
1517
+ return _this2._sessionService.get('/v2/session');
1516
1518
  case 8:
1517
1519
  sessionData = _context.sent;
1518
1520
  _context.next = 15;
@@ -1529,30 +1531,26 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1529
1531
  throw _context.t0;
1530
1532
  case 15:
1531
1533
  if (!sessionData) {
1532
- _context.next = 24;
1534
+ _context.next = 22;
1533
1535
  break;
1534
1536
  }
1535
1537
  if (!_checkRedirectionNeed(sessionData)) {
1536
- _context.next = 23;
1538
+ _context.next = 21;
1537
1539
  break;
1538
1540
  }
1539
- client_sdrn = "sdrn:".concat(_config_js__WEBPACK_IMPORTED_MODULE_58__["NAMESPACE"][_this2.env], ":client:").concat(_this2.clientId);
1540
- redirectBackUrl = _this2.redirectUri.substring(0, _this2.redirectUri.lastIndexOf('/'));
1541
- params = {
1542
- redirect_uri: redirectBackUrl,
1543
- client_sdrn: client_sdrn
1544
- };
1545
- _this2.emit('redirectToSessionService');
1546
- _this2.window.location.href = _this2._sessionService.makeUrl(sessionData.redirectURL.substring(sessionData.redirectURL.lastIndexOf('/')), params);
1541
+ _context.next = 19;
1542
+ return _this2.callbackBeforeRedirect();
1543
+ case 19:
1544
+ _this2.window.location.href = _this2._sessionService.makeUrl(sessionData.redirectURL);
1547
1545
  return _context.abrupt("return");
1548
- case 23:
1546
+ case 21:
1549
1547
  if (_this2._enableSessionCaching) {
1550
1548
  _expiresIn = 1000 * (sessionData.expiresIn || 300);
1551
1549
  _this2.cache.set(HAS_SESSION_CACHE_KEY, sessionData, _expiresIn);
1552
1550
  }
1553
- case 24:
1551
+ case 22:
1554
1552
  return _context.abrupt("return", _postProcess(sessionData));
1555
- case 25:
1553
+ case 23:
1556
1554
  case "end":
1557
1555
  return _context.stop();
1558
1556
  }
@@ -7980,7 +7978,7 @@ __webpack_require__.r(__webpack_exports__);
7980
7978
  /* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(172);
7981
7979
  /* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_9__);
7982
7980
  /* harmony import */ var _SDKError_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(189);
7983
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
7981
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
7984
7982
  * See LICENSE.md in the project root.
7985
7983
  */
7986
7984
 
@@ -9702,7 +9700,7 @@ __webpack_require__.r(__webpack_exports__);
9702
9700
  /* harmony import */ var core_js_modules_es_number_constructor_js__WEBPACK_IMPORTED_MODULE_21___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_number_constructor_js__WEBPACK_IMPORTED_MODULE_21__);
9703
9701
  /* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(172);
9704
9702
  /* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_22___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_22__);
9705
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
9703
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
9706
9704
  * See LICENSE.md in the project root.
9707
9705
  */
9708
9706
 
@@ -10298,7 +10296,7 @@ __webpack_require__.r(__webpack_exports__);
10298
10296
  /* harmony import */ var core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_14__);
10299
10297
  /* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(183);
10300
10298
  /* harmony import */ var _SDKError_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(189);
10301
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10299
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10302
10300
  * See LICENSE.md in the project root.
10303
10301
  */
10304
10302
 
@@ -10349,28 +10347,27 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10349
10347
  * keys for undefined values are removed.
10350
10348
  */
10351
10349
  function cloneDefined() {
10352
- var dest = {};
10350
+ var result = {};
10353
10351
  for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
10354
10352
  sources[_key] = arguments[_key];
10355
10353
  }
10356
10354
  if (!(sources && sources.length)) {
10357
10355
  throw new _SDKError_js__WEBPACK_IMPORTED_MODULE_16__["default"]('No objects to clone');
10358
10356
  }
10359
- sources.forEach(function (src) {
10360
- Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["assert"])(Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isObject"])(src));
10361
- if (Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isNonEmptyObj"])(src)) {
10362
- Object.entries(src).forEach(function (_ref) {
10357
+ sources.forEach(function (source) {
10358
+ Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["assert"])(Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isObject"])(source));
10359
+ if (Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isNonEmptyObj"])(source)) {
10360
+ Object.entries(source).forEach(function (_ref) {
10363
10361
  var _ref2 = _slicedToArray(_ref, 2),
10364
10362
  key = _ref2[0],
10365
- val = _ref2[1];
10366
- if (val !== undefined) {
10367
- // eslint-disable-line no-undefined
10368
- dest[key] = Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isObject"])(val) ? cloneDeep(val) : val;
10363
+ value = _ref2[1];
10364
+ if (typeof value !== 'undefined') {
10365
+ result[key] = Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isObject"])(value) ? cloneDeep(value) : value;
10369
10366
  }
10370
10367
  });
10371
10368
  }
10372
10369
  });
10373
- return dest;
10370
+ return result;
10374
10371
  }
10375
10372
 
10376
10373
  /**
@@ -10587,7 +10584,7 @@ __webpack_require__.r(__webpack_exports__);
10587
10584
  /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(173);
10588
10585
  /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_6__);
10589
10586
  /* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(183);
10590
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10587
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10591
10588
  * See LICENSE.md in the project root.
10592
10589
  */
10593
10590
 
@@ -10629,7 +10626,7 @@ function urlMapper(url, urlMap) {
10629
10626
  __webpack_require__.r(__webpack_exports__);
10630
10627
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ENDPOINTS", function() { return ENDPOINTS; });
10631
10628
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NAMESPACE", function() { return NAMESPACE; });
10632
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10629
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10633
10630
  * See LICENSE.md in the project root.
10634
10631
  */
10635
10632
 
@@ -10816,7 +10813,7 @@ __webpack_require__.r(__webpack_exports__);
10816
10813
  /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(173);
10817
10814
  /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_13__);
10818
10815
  /* harmony import */ var _SDKError_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(189);
10819
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10816
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10820
10817
  * See LICENSE.md in the project root.
10821
10818
  */
10822
10819
 
@@ -11354,7 +11351,7 @@ __webpack_require__.r(__webpack_exports__);
11354
11351
 
11355
11352
 
11356
11353
 
11357
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11354
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11358
11355
  * See LICENSE.md in the project root.
11359
11356
  */
11360
11357
 
@@ -11513,7 +11510,7 @@ __webpack_require__.r(__webpack_exports__);
11513
11510
  /* harmony import */ var _object_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(197);
11514
11511
  /* harmony import */ var _url_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(203);
11515
11512
  /* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(183);
11516
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11513
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11517
11514
  * See LICENSE.md in the project root.
11518
11515
  */
11519
11516
 
@@ -11868,7 +11865,7 @@ __webpack_require__.r(__webpack_exports__);
11868
11865
  /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(173);
11869
11866
  /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_6__);
11870
11867
  /* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(183);
11871
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11868
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11872
11869
  * See LICENSE.md in the project root.
11873
11870
  */
11874
11871
 
@@ -11927,7 +11924,7 @@ __webpack_require__.r(__webpack_exports__);
11927
11924
 
11928
11925
 
11929
11926
 
11930
- var version = '4.8.6-beta.2';
11927
+ var version = '4.8.7-beta.2';
11931
11928
  /* harmony default export */ __webpack_exports__["default"] = (version);
11932
11929
 
11933
11930
  /***/ })