@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/index.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
 
@@ -889,7 +889,7 @@ __webpack_require__.r(__webpack_exports__);
889
889
  /* harmony import */ var _SDKError_js__WEBPACK_IMPORTED_MODULE_63__ = __webpack_require__(189);
890
890
  /* harmony import */ var _spidTalk_js__WEBPACK_IMPORTED_MODULE_64__ = __webpack_require__(217);
891
891
  /* harmony import */ var _version_js__WEBPACK_IMPORTED_MODULE_65__ = __webpack_require__(218);
892
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
892
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
893
893
  * See LICENSE.md in the project root.
894
894
  */
895
895
 
@@ -1126,6 +1126,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1126
1126
  * @param {function} [options.log] - A function that receives debug log information. If not set,
1127
1127
  * no logging will be done
1128
1128
  * @param {object} [options.window] - window object
1129
+ * @param {function} [options.callbackBeforeRedirect] - callback triggered before session refresh redirect happen
1129
1130
  * @throws {SDKError} - If any of options are invalid
1130
1131
  */
1131
1132
  function Identity(_ref) {
@@ -1137,7 +1138,9 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1137
1138
  env = _ref$env === void 0 ? 'PRE' : _ref$env,
1138
1139
  log = _ref.log,
1139
1140
  _ref$window = _ref.window,
1140
- window = _ref$window === void 0 ? globalWindow() : _ref$window;
1141
+ window = _ref$window === void 0 ? globalWindow() : _ref$window,
1142
+ _ref$callbackBeforeRe = _ref.callbackBeforeRedirect,
1143
+ callbackBeforeRedirect = _ref$callbackBeforeRe === void 0 ? function () {} : _ref$callbackBeforeRe;
1141
1144
  _classCallCheck(this, Identity);
1142
1145
  _this = _super.call(this);
1143
1146
  Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["assert"])(Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["isNonEmptyString"])(clientId), 'clientId parameter is required');
@@ -1154,6 +1157,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1154
1157
  _this.redirectUri = redirectUri;
1155
1158
  _this.env = env;
1156
1159
  _this.log = log;
1160
+ _this.callbackBeforeRedirect = callbackBeforeRedirect;
1157
1161
  _this._sessionDomain = sessionDomain;
1158
1162
 
1159
1163
  // Internal hack: set to false to always refresh from hassession
@@ -1373,10 +1377,8 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1373
1377
  if (Number.isInteger(options)) {
1374
1378
  expiresIn = options;
1375
1379
  } else if (_typeof(options) == 'object') {
1376
- var _options$expiresIn = options.expiresIn;
1377
- expiresIn = _options$expiresIn === void 0 ? expiresIn : _options$expiresIn;
1378
- var _options$domain = options.domain;
1379
- domain = _options$domain === void 0 ? domain : _options$domain;
1380
+ expiresIn = options.expiresIn || expiresIn;
1381
+ domain = options.domain || domain;
1380
1382
  }
1381
1383
  Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["assert"])(Number.isInteger(expiresIn), "'expiresIn' must be an integer");
1382
1384
  Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["assert"])(expiresIn >= 0, "'expiresIn' cannot be negative");
@@ -1433,7 +1435,8 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1433
1435
  }, {
1434
1436
  key: "_clearVarnishCookie",
1435
1437
  value: function _clearVarnishCookie() {
1436
- var domain = this.varnishCookieDomain || (this._session && typeof this._session.baseDomain === 'string' ? this._session.baseDomain : document.domain) || '';
1438
+ var baseDomain = this._session && typeof this._session.baseDomain === 'string' ? this._session.baseDomain : document.domain;
1439
+ var domain = this.varnishCookieDomain || baseDomain || '';
1437
1440
  document.cookie = "SP_ID=nothing; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=.".concat(domain);
1438
1441
  }
1439
1442
 
@@ -1494,12 +1497,11 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1494
1497
  var _checkRedirectionNeed = function _checkRedirectionNeed() {
1495
1498
  var sessionData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1496
1499
  var sessionDataKeys = Object.keys(sessionData);
1497
- var isRedirectNeeded = sessionDataKeys.length === 1 && sessionDataKeys[0] === 'redirectURL';
1498
- return isRedirectNeeded;
1500
+ return sessionDataKeys.length === 1 && sessionDataKeys[0] === 'redirectURL';
1499
1501
  };
1500
1502
  var _getSession = /*#__PURE__*/function () {
1501
1503
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1502
- var cachedSession, sessionData, expiresIn, client_sdrn, redirectBackUrl, params, _expiresIn;
1504
+ var cachedSession, sessionData, expiresIn, _expiresIn;
1503
1505
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1504
1506
  while (1) switch (_context.prev = _context.next) {
1505
1507
  case 0:
@@ -1518,7 +1520,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1518
1520
  sessionData = null;
1519
1521
  _context.prev = 5;
1520
1522
  _context.next = 8;
1521
- return _this2._sessionService.get('/session');
1523
+ return _this2._sessionService.get('/v2/session');
1522
1524
  case 8:
1523
1525
  sessionData = _context.sent;
1524
1526
  _context.next = 15;
@@ -1535,30 +1537,28 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
1535
1537
  throw _context.t0;
1536
1538
  case 15:
1537
1539
  if (!sessionData) {
1538
- _context.next = 24;
1540
+ _context.next = 22;
1539
1541
  break;
1540
1542
  }
1541
1543
  if (!_checkRedirectionNeed(sessionData)) {
1542
- _context.next = 23;
1544
+ _context.next = 21;
1543
1545
  break;
1544
1546
  }
1545
- client_sdrn = "sdrn:".concat(_config_js__WEBPACK_IMPORTED_MODULE_58__["NAMESPACE"][_this2.env], ":client:").concat(_this2.clientId);
1546
- redirectBackUrl = _this2.redirectUri.substring(0, _this2.redirectUri.lastIndexOf('/'));
1547
- params = {
1548
- redirect_uri: redirectBackUrl,
1549
- client_sdrn: client_sdrn
1550
- };
1551
- _this2.emit('redirectToSessionService');
1552
- _this2.window.location.href = _this2._sessionService.makeUrl(sessionData.redirectURL.substring(sessionData.redirectURL.lastIndexOf('/')), params);
1547
+ _context.next = 19;
1548
+ return _this2.callbackBeforeRedirect();
1549
+ case 19:
1550
+ _this2.window.location.href = _this2._sessionService.makeUrl(sessionData.redirectURL, {
1551
+ redirect_uri: _this2.window.location.origin
1552
+ });
1553
1553
  return _context.abrupt("return");
1554
- case 23:
1554
+ case 21:
1555
1555
  if (_this2._enableSessionCaching) {
1556
1556
  _expiresIn = 1000 * (sessionData.expiresIn || 300);
1557
1557
  _this2.cache.set(HAS_SESSION_CACHE_KEY, sessionData, _expiresIn);
1558
1558
  }
1559
- case 24:
1559
+ case 22:
1560
1560
  return _context.abrupt("return", _postProcess(sessionData));
1561
- case 25:
1561
+ case 23:
1562
1562
  case "end":
1563
1563
  return _context.stop();
1564
1564
  }
@@ -7986,7 +7986,7 @@ __webpack_require__.r(__webpack_exports__);
7986
7986
  /* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(172);
7987
7987
  /* 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__);
7988
7988
  /* harmony import */ var _SDKError_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(189);
7989
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
7989
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
7990
7990
  * See LICENSE.md in the project root.
7991
7991
  */
7992
7992
 
@@ -9708,7 +9708,7 @@ __webpack_require__.r(__webpack_exports__);
9708
9708
  /* 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__);
9709
9709
  /* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(172);
9710
9710
  /* 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__);
9711
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
9711
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
9712
9712
  * See LICENSE.md in the project root.
9713
9713
  */
9714
9714
 
@@ -10304,7 +10304,7 @@ __webpack_require__.r(__webpack_exports__);
10304
10304
  /* 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__);
10305
10305
  /* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(183);
10306
10306
  /* harmony import */ var _SDKError_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(189);
10307
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10307
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10308
10308
  * See LICENSE.md in the project root.
10309
10309
  */
10310
10310
 
@@ -10355,28 +10355,27 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10355
10355
  * keys for undefined values are removed.
10356
10356
  */
10357
10357
  function cloneDefined() {
10358
- var dest = {};
10358
+ var result = {};
10359
10359
  for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
10360
10360
  sources[_key] = arguments[_key];
10361
10361
  }
10362
10362
  if (!(sources && sources.length)) {
10363
10363
  throw new _SDKError_js__WEBPACK_IMPORTED_MODULE_16__["default"]('No objects to clone');
10364
10364
  }
10365
- sources.forEach(function (src) {
10366
- Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["assert"])(Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isObject"])(src));
10367
- if (Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isNonEmptyObj"])(src)) {
10368
- Object.entries(src).forEach(function (_ref) {
10365
+ sources.forEach(function (source) {
10366
+ Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["assert"])(Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isObject"])(source));
10367
+ if (Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isNonEmptyObj"])(source)) {
10368
+ Object.entries(source).forEach(function (_ref) {
10369
10369
  var _ref2 = _slicedToArray(_ref, 2),
10370
10370
  key = _ref2[0],
10371
- val = _ref2[1];
10372
- if (val !== undefined) {
10373
- // eslint-disable-line no-undefined
10374
- dest[key] = Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isObject"])(val) ? cloneDeep(val) : val;
10371
+ value = _ref2[1];
10372
+ if (typeof value !== 'undefined') {
10373
+ result[key] = Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isObject"])(value) ? cloneDeep(value) : value;
10375
10374
  }
10376
10375
  });
10377
10376
  }
10378
10377
  });
10379
- return dest;
10378
+ return result;
10380
10379
  }
10381
10380
 
10382
10381
  /**
@@ -10593,7 +10592,7 @@ __webpack_require__.r(__webpack_exports__);
10593
10592
  /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(173);
10594
10593
  /* 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__);
10595
10594
  /* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(183);
10596
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10595
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10597
10596
  * See LICENSE.md in the project root.
10598
10597
  */
10599
10598
 
@@ -10635,7 +10634,7 @@ function urlMapper(url, urlMap) {
10635
10634
  __webpack_require__.r(__webpack_exports__);
10636
10635
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ENDPOINTS", function() { return ENDPOINTS; });
10637
10636
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NAMESPACE", function() { return NAMESPACE; });
10638
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10637
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10639
10638
  * See LICENSE.md in the project root.
10640
10639
  */
10641
10640
 
@@ -10822,7 +10821,7 @@ __webpack_require__.r(__webpack_exports__);
10822
10821
  /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(173);
10823
10822
  /* 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__);
10824
10823
  /* harmony import */ var _SDKError_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(189);
10825
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10824
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10826
10825
  * See LICENSE.md in the project root.
10827
10826
  */
10828
10827
 
@@ -11360,7 +11359,7 @@ __webpack_require__.r(__webpack_exports__);
11360
11359
 
11361
11360
 
11362
11361
 
11363
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11362
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11364
11363
  * See LICENSE.md in the project root.
11365
11364
  */
11366
11365
 
@@ -11519,7 +11518,7 @@ __webpack_require__.r(__webpack_exports__);
11519
11518
  /* harmony import */ var _object_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(197);
11520
11519
  /* harmony import */ var _url_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(203);
11521
11520
  /* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(183);
11522
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11521
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11523
11522
  * See LICENSE.md in the project root.
11524
11523
  */
11525
11524
 
@@ -11874,7 +11873,7 @@ __webpack_require__.r(__webpack_exports__);
11874
11873
  /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(173);
11875
11874
  /* 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__);
11876
11875
  /* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(183);
11877
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11876
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11878
11877
  * See LICENSE.md in the project root.
11879
11878
  */
11880
11879
 
@@ -11933,7 +11932,7 @@ __webpack_require__.r(__webpack_exports__);
11933
11932
 
11934
11933
 
11935
11934
 
11936
- var version = '4.8.6-beta.2';
11935
+ var version = '4.8.7-beta';
11937
11936
  /* harmony default export */ __webpack_exports__["default"] = (version);
11938
11937
 
11939
11938
  /***/ }),
@@ -12001,7 +12000,7 @@ __webpack_require__.r(__webpack_exports__);
12001
12000
  /* harmony import */ var _spidTalk_js__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(217);
12002
12001
  /* harmony import */ var _SDKError_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(189);
12003
12002
  /* harmony import */ var _version_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(218);
12004
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
12003
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
12005
12004
  * See LICENSE.md in the project root.
12006
12005
  */
12007
12006
 
@@ -12346,7 +12345,7 @@ __webpack_require__.r(__webpack_exports__);
12346
12345
  /* harmony import */ var _popup_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(211);
12347
12346
  /* harmony import */ var _RESTClient_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(214);
12348
12347
  /* harmony import */ var _spidTalk_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(217);
12349
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
12348
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
12350
12349
  * See LICENSE.md in the project root.
12351
12350
  */
12352
12351