@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/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,26 @@ 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);
1553
1551
  return _context.abrupt("return");
1554
- case 23:
1552
+ case 21:
1555
1553
  if (_this2._enableSessionCaching) {
1556
1554
  _expiresIn = 1000 * (sessionData.expiresIn || 300);
1557
1555
  _this2.cache.set(HAS_SESSION_CACHE_KEY, sessionData, _expiresIn);
1558
1556
  }
1559
- case 24:
1557
+ case 22:
1560
1558
  return _context.abrupt("return", _postProcess(sessionData));
1561
- case 25:
1559
+ case 23:
1562
1560
  case "end":
1563
1561
  return _context.stop();
1564
1562
  }
@@ -7986,7 +7984,7 @@ __webpack_require__.r(__webpack_exports__);
7986
7984
  /* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(172);
7987
7985
  /* 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
7986
  /* 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.
7987
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
7990
7988
  * See LICENSE.md in the project root.
7991
7989
  */
7992
7990
 
@@ -9708,7 +9706,7 @@ __webpack_require__.r(__webpack_exports__);
9708
9706
  /* 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
9707
  /* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(172);
9710
9708
  /* 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.
9709
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
9712
9710
  * See LICENSE.md in the project root.
9713
9711
  */
9714
9712
 
@@ -10304,7 +10302,7 @@ __webpack_require__.r(__webpack_exports__);
10304
10302
  /* 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
10303
  /* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(183);
10306
10304
  /* 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.
10305
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10308
10306
  * See LICENSE.md in the project root.
10309
10307
  */
10310
10308
 
@@ -10355,28 +10353,27 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10355
10353
  * keys for undefined values are removed.
10356
10354
  */
10357
10355
  function cloneDefined() {
10358
- var dest = {};
10356
+ var result = {};
10359
10357
  for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
10360
10358
  sources[_key] = arguments[_key];
10361
10359
  }
10362
10360
  if (!(sources && sources.length)) {
10363
10361
  throw new _SDKError_js__WEBPACK_IMPORTED_MODULE_16__["default"]('No objects to clone');
10364
10362
  }
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) {
10363
+ sources.forEach(function (source) {
10364
+ Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["assert"])(Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isObject"])(source));
10365
+ if (Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isNonEmptyObj"])(source)) {
10366
+ Object.entries(source).forEach(function (_ref) {
10369
10367
  var _ref2 = _slicedToArray(_ref, 2),
10370
10368
  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;
10369
+ value = _ref2[1];
10370
+ if (typeof value !== 'undefined') {
10371
+ result[key] = Object(_validate_js__WEBPACK_IMPORTED_MODULE_15__["isObject"])(value) ? cloneDeep(value) : value;
10375
10372
  }
10376
10373
  });
10377
10374
  }
10378
10375
  });
10379
- return dest;
10376
+ return result;
10380
10377
  }
10381
10378
 
10382
10379
  /**
@@ -10593,7 +10590,7 @@ __webpack_require__.r(__webpack_exports__);
10593
10590
  /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(173);
10594
10591
  /* 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
10592
  /* 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.
10593
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10597
10594
  * See LICENSE.md in the project root.
10598
10595
  */
10599
10596
 
@@ -10635,7 +10632,7 @@ function urlMapper(url, urlMap) {
10635
10632
  __webpack_require__.r(__webpack_exports__);
10636
10633
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ENDPOINTS", function() { return ENDPOINTS; });
10637
10634
  /* 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.
10635
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10639
10636
  * See LICENSE.md in the project root.
10640
10637
  */
10641
10638
 
@@ -10822,7 +10819,7 @@ __webpack_require__.r(__webpack_exports__);
10822
10819
  /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(173);
10823
10820
  /* 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
10821
  /* 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.
10822
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
10826
10823
  * See LICENSE.md in the project root.
10827
10824
  */
10828
10825
 
@@ -11360,7 +11357,7 @@ __webpack_require__.r(__webpack_exports__);
11360
11357
 
11361
11358
 
11362
11359
 
11363
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11360
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11364
11361
  * See LICENSE.md in the project root.
11365
11362
  */
11366
11363
 
@@ -11519,7 +11516,7 @@ __webpack_require__.r(__webpack_exports__);
11519
11516
  /* harmony import */ var _object_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(197);
11520
11517
  /* harmony import */ var _url_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(203);
11521
11518
  /* 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.
11519
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11523
11520
  * See LICENSE.md in the project root.
11524
11521
  */
11525
11522
 
@@ -11874,7 +11871,7 @@ __webpack_require__.r(__webpack_exports__);
11874
11871
  /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(173);
11875
11872
  /* 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
11873
  /* 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.
11874
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
11878
11875
  * See LICENSE.md in the project root.
11879
11876
  */
11880
11877
 
@@ -11933,7 +11930,7 @@ __webpack_require__.r(__webpack_exports__);
11933
11930
 
11934
11931
 
11935
11932
 
11936
- var version = '4.8.6-beta.2';
11933
+ var version = '4.8.7-beta.2';
11937
11934
  /* harmony default export */ __webpack_exports__["default"] = (version);
11938
11935
 
11939
11936
  /***/ }),
@@ -12001,7 +11998,7 @@ __webpack_require__.r(__webpack_exports__);
12001
11998
  /* harmony import */ var _spidTalk_js__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(217);
12002
11999
  /* harmony import */ var _SDKError_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(189);
12003
12000
  /* 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.
12001
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
12005
12002
  * See LICENSE.md in the project root.
12006
12003
  */
12007
12004
 
@@ -12346,7 +12343,7 @@ __webpack_require__.r(__webpack_exports__);
12346
12343
  /* harmony import */ var _popup_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(211);
12347
12344
  /* harmony import */ var _RESTClient_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(214);
12348
12345
  /* 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.
12346
+ /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
12350
12347
  * See LICENSE.md in the project root.
12351
12348
  */
12352
12349