@schibsted/account-sdk-browser 4.8.6-beta.2 → 4.8.7-beta

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,28 @@ 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, {
1545
+ redirect_uri: _this2.window.location.origin
1546
+ });
1547
1547
  return _context.abrupt("return");
1548
- case 23:
1548
+ case 21:
1549
1549
  if (_this2._enableSessionCaching) {
1550
1550
  _expiresIn = 1000 * (sessionData.expiresIn || 300);
1551
1551
  _this2.cache.set(HAS_SESSION_CACHE_KEY, sessionData, _expiresIn);
1552
1552
  }
1553
- case 24:
1553
+ case 22:
1554
1554
  return _context.abrupt("return", _postProcess(sessionData));
1555
- case 25:
1555
+ case 23:
1556
1556
  case "end":
1557
1557
  return _context.stop();
1558
1558
  }
@@ -7980,7 +7980,7 @@ __webpack_require__.r(__webpack_exports__);
7980
7980
  /* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(172);
7981
7981
  /* 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
7982
  /* 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.
7983
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
7984
7984
  * See LICENSE.md in the project root.
7985
7985
  */
7986
7986
 
@@ -9702,7 +9702,7 @@ __webpack_require__.r(__webpack_exports__);
9702
9702
  /* 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
9703
  /* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(172);
9704
9704
  /* 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.
9705
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
9706
9706
  * See LICENSE.md in the project root.
9707
9707
  */
9708
9708
 
@@ -10298,7 +10298,7 @@ __webpack_require__.r(__webpack_exports__);
10298
10298
  /* 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
10299
  /* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(183);
10300
10300
  /* 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.
10301
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10302
10302
  * See LICENSE.md in the project root.
10303
10303
  */
10304
10304
 
@@ -10349,28 +10349,27 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10349
10349
  * keys for undefined values are removed.
10350
10350
  */
10351
10351
  function cloneDefined() {
10352
- var dest = {};
10352
+ var result = {};
10353
10353
  for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
10354
10354
  sources[_key] = arguments[_key];
10355
10355
  }
10356
10356
  if (!(sources && sources.length)) {
10357
10357
  throw new _SDKError_js__WEBPACK_IMPORTED_MODULE_16__["default"]('No objects to clone');
10358
10358
  }
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) {
10359
+ sources.forEach(function (source) {
10360
+ Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["assert"])(Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isObject"])(source));
10361
+ if (Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isNonEmptyObj"])(source)) {
10362
+ Object.entries(source).forEach(function (_ref) {
10363
10363
  var _ref2 = _slicedToArray(_ref, 2),
10364
10364
  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;
10365
+ value = _ref2[1];
10366
+ if (typeof value !== 'undefined') {
10367
+ result[key] = Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isObject"])(value) ? cloneDeep(value) : value;
10369
10368
  }
10370
10369
  });
10371
10370
  }
10372
10371
  });
10373
- return dest;
10372
+ return result;
10374
10373
  }
10375
10374
 
10376
10375
  /**
@@ -10587,7 +10586,7 @@ __webpack_require__.r(__webpack_exports__);
10587
10586
  /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(173);
10588
10587
  /* 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
10588
  /* 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.
10589
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10591
10590
  * See LICENSE.md in the project root.
10592
10591
  */
10593
10592
 
@@ -10629,7 +10628,7 @@ function urlMapper(url, urlMap) {
10629
10628
  __webpack_require__.r(__webpack_exports__);
10630
10629
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ENDPOINTS", function() { return ENDPOINTS; });
10631
10630
  /* 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.
10631
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10633
10632
  * See LICENSE.md in the project root.
10634
10633
  */
10635
10634
 
@@ -10816,7 +10815,7 @@ __webpack_require__.r(__webpack_exports__);
10816
10815
  /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(173);
10817
10816
  /* 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
10817
  /* 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.
10818
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10820
10819
  * See LICENSE.md in the project root.
10821
10820
  */
10822
10821
 
@@ -11354,7 +11353,7 @@ __webpack_require__.r(__webpack_exports__);
11354
11353
 
11355
11354
 
11356
11355
 
11357
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11356
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11358
11357
  * See LICENSE.md in the project root.
11359
11358
  */
11360
11359
 
@@ -11513,7 +11512,7 @@ __webpack_require__.r(__webpack_exports__);
11513
11512
  /* harmony import */ var _object_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(197);
11514
11513
  /* harmony import */ var _url_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(203);
11515
11514
  /* 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.
11515
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11517
11516
  * See LICENSE.md in the project root.
11518
11517
  */
11519
11518
 
@@ -11868,7 +11867,7 @@ __webpack_require__.r(__webpack_exports__);
11868
11867
  /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(173);
11869
11868
  /* 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
11869
  /* 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.
11870
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11872
11871
  * See LICENSE.md in the project root.
11873
11872
  */
11874
11873
 
@@ -11927,7 +11926,7 @@ __webpack_require__.r(__webpack_exports__);
11927
11926
 
11928
11927
 
11929
11928
 
11930
- var version = '4.8.6-beta.2';
11929
+ var version = '4.8.7-beta';
11931
11930
  /* harmony default export */ __webpack_exports__["default"] = (version);
11932
11931
 
11933
11932
  /***/ })