@schibsted/account-sdk-browser 5.0.0-beta.2 → 5.0.1-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/global.js +29 -36
- package/es5/global.js.map +1 -1
- package/es5/global.min.js +1 -1
- package/es5/global.min.js.map +1 -1
- package/es5/identity.js +29 -36
- package/es5/identity.js.map +1 -1
- package/es5/identity.min.js +1 -1
- package/es5/identity.min.js.map +1 -1
- package/es5/index.js +29 -36
- package/es5/index.js.map +1 -1
- package/es5/index.min.js +1 -1
- package/es5/index.min.js.map +1 -1
- package/es5/monetization.js +1 -4
- package/es5/monetization.js.map +1 -1
- package/es5/monetization.min.js +1 -1
- package/es5/monetization.min.js.map +1 -1
- package/package.json +1 -1
- package/src/cache.d.ts +0 -3
- package/src/cache.js +0 -3
- package/src/identity.d.ts +9 -12
- package/src/identity.js +31 -29
- package/src/version.js +1 -1
package/es5/index.js
CHANGED
|
@@ -988,7 +988,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
988
988
|
* `password` (will force password confirmation, even if user is already logged in), `eid`. Those values might
|
|
989
989
|
* be mixed as space-separated string. To make sure that user has authenticated with 2FA you need
|
|
990
990
|
* to verify AMR (Authentication Methods References) claim in ID token.
|
|
991
|
-
* Might also be used to ensure additional acr (sms, otp) for already logged
|
|
991
|
+
* Might also be used to ensure additional acr (sms, otp) for already logged-in users.
|
|
992
992
|
* Supported value is also 'otp-email' means one time password using email.
|
|
993
993
|
* @property {string} [scope] - The OAuth scopes for the tokens. This is a list of
|
|
994
994
|
* scopes, separated by space. If the list of scopes contains `openid`, the generated tokens
|
|
@@ -1022,7 +1022,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
1022
1022
|
* `password` (will force password confirmation, even if user is already logged in). Those values might
|
|
1023
1023
|
* be mixed as space-separated string. To make sure that user has authenticated with 2FA you need
|
|
1024
1024
|
* to verify AMR (Authentication Methods References) claim in ID token.
|
|
1025
|
-
* Might also be used to ensure additional acr (sms, otp) for already logged
|
|
1025
|
+
* Might also be used to ensure additional acr (sms, otp) for already logged-in users.
|
|
1026
1026
|
* Supported value is also 'otp-email' means one time password using email.
|
|
1027
1027
|
* @property {string} [scope] - The OAuth scopes for the tokens. This is a list of
|
|
1028
1028
|
* scopes, separated by space. If the list of scopes contains `openid`, the generated tokens
|
|
@@ -1096,7 +1096,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
1096
1096
|
|
|
1097
1097
|
/**
|
|
1098
1098
|
* @typedef {object} SimplifiedLoginData
|
|
1099
|
-
* @property {string} identifier - Deprecated: User UUID, to be
|
|
1099
|
+
* @property {string} identifier - Deprecated: User UUID, to be as `loginHint` for {@link Identity#login}
|
|
1100
1100
|
* @property {string} display_text - Human-readable user identifier
|
|
1101
1101
|
* @property {string} client_name - Client name
|
|
1102
1102
|
*/
|
|
@@ -1108,7 +1108,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
1108
1108
|
|
|
1109
1109
|
var HAS_SESSION_CACHE_KEY = 'hasSession-cache';
|
|
1110
1110
|
var SESSION_CALL_BLOCKED_CACHE_KEY = 'sessionCallBlocked-cache';
|
|
1111
|
-
var SESSION_CALL_BLOCKED_TTL = 1000 *
|
|
1111
|
+
var SESSION_CALL_BLOCKED_TTL = 1000 * 30;
|
|
1112
1112
|
var TAB_ID_KEY = 'tab-id-cache';
|
|
1113
1113
|
var TAB_ID = Math.floor(Math.random() * 100000);
|
|
1114
1114
|
var TAB_ID_TTL = 1000 * 60 * 60 * 24 * 30;
|
|
@@ -1117,7 +1117,7 @@ var globalWindow = function globalWindow() {
|
|
|
1117
1117
|
};
|
|
1118
1118
|
|
|
1119
1119
|
/**
|
|
1120
|
-
* Provides Identity
|
|
1120
|
+
* Provides Identity functionality to a web page
|
|
1121
1121
|
*/
|
|
1122
1122
|
var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
1123
1123
|
_inherits(Identity, _EventEmitter);
|
|
@@ -1153,23 +1153,20 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
1153
1153
|
Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["assert"])(!redirectUri || Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["isUrl"])(redirectUri), 'redirectUri parameter is invalid');
|
|
1154
1154
|
Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["assert"])(sessionDomain && Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["isUrl"])(sessionDomain), 'sessionDomain parameter is not a valid URL');
|
|
1155
1155
|
_spidTalk_js__WEBPACK_IMPORTED_MODULE_64__["emulate"](window);
|
|
1156
|
+
|
|
1157
|
+
// Internal hack: set as false to always refresh from hasSession
|
|
1158
|
+
_this._enableSessionCaching = true;
|
|
1156
1159
|
_this._sessionInitiatedSent = false;
|
|
1157
1160
|
_this.window = window;
|
|
1158
1161
|
_this.clientId = clientId;
|
|
1159
|
-
_this.sessionStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](
|
|
1160
|
-
|
|
1161
|
-
});
|
|
1162
|
-
_this.localStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](function () {
|
|
1163
|
-
return _this.window && _this.window.localStorage;
|
|
1164
|
-
});
|
|
1162
|
+
_this.sessionStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](_this.window && _this.window.sessionStorage);
|
|
1163
|
+
_this.localStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](_this.window && _this.window.localStorage);
|
|
1165
1164
|
_this.redirectUri = redirectUri;
|
|
1166
1165
|
_this.env = env;
|
|
1167
1166
|
_this.log = log;
|
|
1168
1167
|
_this.callbackBeforeRedirect = callbackBeforeRedirect;
|
|
1169
1168
|
_this._sessionDomain = sessionDomain;
|
|
1170
|
-
|
|
1171
|
-
// Internal hack: set to false to always refresh from hassession
|
|
1172
|
-
_this._enableSessionCaching = true;
|
|
1169
|
+
_this._tabId = _this._getTabId();
|
|
1173
1170
|
|
|
1174
1171
|
// Old session
|
|
1175
1172
|
_this._session = {};
|
|
@@ -1178,12 +1175,12 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
1178
1175
|
_this._setBffServerUrl(env);
|
|
1179
1176
|
_this._setOauthServerUrl(env);
|
|
1180
1177
|
_this._setGlobalSessionServiceUrl(env);
|
|
1181
|
-
_this.
|
|
1178
|
+
_this._unblockSessionCallByTab();
|
|
1182
1179
|
return _this;
|
|
1183
1180
|
}
|
|
1184
1181
|
|
|
1185
1182
|
/**
|
|
1186
|
-
* Read tabId from session storage
|
|
1183
|
+
* Read tabId from session storage if possible, otherwise save tabId to session storage and return it
|
|
1187
1184
|
* @returns {number}
|
|
1188
1185
|
* @private
|
|
1189
1186
|
*/
|
|
@@ -1198,13 +1195,13 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
1198
1195
|
}
|
|
1199
1196
|
return tabId;
|
|
1200
1197
|
}
|
|
1198
|
+
return TAB_ID;
|
|
1201
1199
|
}
|
|
1202
1200
|
|
|
1203
1201
|
/**
|
|
1204
|
-
* Checks if
|
|
1202
|
+
* Checks if calling GET session is blocked
|
|
1205
1203
|
* @private
|
|
1206
|
-
*
|
|
1207
|
-
* @returns {boolean|void}
|
|
1204
|
+
* @returns {number|null}
|
|
1208
1205
|
*/
|
|
1209
1206
|
}, {
|
|
1210
1207
|
key: "_isSessionCallBlocked",
|
|
@@ -1213,28 +1210,27 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
1213
1210
|
}
|
|
1214
1211
|
|
|
1215
1212
|
/**
|
|
1216
|
-
* Block calls to get session
|
|
1213
|
+
* Block calls to get session. This is done to prevent concurrent calls which can log user out if session is refreshed by one of them
|
|
1217
1214
|
* @private
|
|
1218
|
-
*
|
|
1219
1215
|
* @returns {void}
|
|
1220
1216
|
*/
|
|
1221
1217
|
}, {
|
|
1222
1218
|
key: "_blockSessionCall",
|
|
1223
1219
|
value: function _blockSessionCall() {
|
|
1224
|
-
|
|
1225
|
-
this.localStorageCache.set(SESSION_CALL_BLOCKED_CACHE_KEY, SESSION_CALL_BLOCKED, SESSION_CALL_BLOCKED_TTL);
|
|
1220
|
+
this.localStorageCache.set(SESSION_CALL_BLOCKED_CACHE_KEY, this._tabId, SESSION_CALL_BLOCKED_TTL);
|
|
1226
1221
|
}
|
|
1227
1222
|
|
|
1228
1223
|
/**
|
|
1229
|
-
* Unblocks calls to get session
|
|
1224
|
+
* Unblocks calls to get session if the lock was put by the same tab
|
|
1230
1225
|
* @private
|
|
1231
|
-
*
|
|
1232
1226
|
* @returns {void}
|
|
1233
1227
|
*/
|
|
1234
1228
|
}, {
|
|
1235
|
-
key: "
|
|
1236
|
-
value: function
|
|
1237
|
-
this.
|
|
1229
|
+
key: "_unblockSessionCallByTab",
|
|
1230
|
+
value: function _unblockSessionCallByTab() {
|
|
1231
|
+
if (this._isSessionCallBlocked() === this._tabId) {
|
|
1232
|
+
this.localStorageCache.delete(SESSION_CALL_BLOCKED_CACHE_KEY);
|
|
1233
|
+
}
|
|
1238
1234
|
}
|
|
1239
1235
|
|
|
1240
1236
|
/**
|
|
@@ -1341,7 +1337,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
1341
1337
|
}
|
|
1342
1338
|
|
|
1343
1339
|
/**
|
|
1344
|
-
* Emits the relevant events based on the previous and new reply from
|
|
1340
|
+
* Emits the relevant events based on the previous and new reply from {@link Identity#hasSession}
|
|
1345
1341
|
* @private
|
|
1346
1342
|
* @param {object} previous
|
|
1347
1343
|
* @param {object} current
|
|
@@ -1425,7 +1421,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
1425
1421
|
}
|
|
1426
1422
|
|
|
1427
1423
|
/**
|
|
1428
|
-
* Set the Varnish cookie (`SP_ID`) when hasSession
|
|
1424
|
+
* Set the Varnish cookie (`SP_ID`) when {@link Identity#hasSession} is called. Note that most browsers require
|
|
1429
1425
|
* that you are on a "real domain" for this to work — so, **not** `localhost`
|
|
1430
1426
|
* @param {object} [options]
|
|
1431
1427
|
* @param {number} [options.expiresIn] Override this to set number of seconds before the varnish
|
|
@@ -1589,7 +1585,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
1589
1585
|
_context.prev = 5;
|
|
1590
1586
|
_context.next = 8;
|
|
1591
1587
|
return _this2._sessionService.get('/v2/session', {
|
|
1592
|
-
tabId: _this2.
|
|
1588
|
+
tabId: _this2._tabId
|
|
1593
1589
|
});
|
|
1594
1590
|
case 8:
|
|
1595
1591
|
sessionData = _context.sent;
|
|
@@ -1789,7 +1785,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
1789
1785
|
* @description This function calls {@link Identity#hasSession} internally and thus has the side
|
|
1790
1786
|
* effect that it might perform an auto-login on the user
|
|
1791
1787
|
* @throws {SDKError} If the user isn't connected to the merchant
|
|
1792
|
-
* @return {
|
|
1788
|
+
* @return {number} The `userId` field (not to be confused with the `uuid`)
|
|
1793
1789
|
*/
|
|
1794
1790
|
}, {
|
|
1795
1791
|
key: "getUserId",
|
|
@@ -11020,7 +11016,6 @@ var Cache = /*#__PURE__*/function () {
|
|
|
11020
11016
|
/**
|
|
11021
11017
|
* Get a value from cache (checks that the object has not expired)
|
|
11022
11018
|
* @param {string} key
|
|
11023
|
-
* @private
|
|
11024
11019
|
* @returns {*} - The value if it exists, otherwise null
|
|
11025
11020
|
*/
|
|
11026
11021
|
_createClass(Cache, [{
|
|
@@ -11056,7 +11051,6 @@ var Cache = /*#__PURE__*/function () {
|
|
|
11056
11051
|
* @param {string} key
|
|
11057
11052
|
* @param {*} value
|
|
11058
11053
|
* @param {Number} expiresIn - Value in milliseconds until the entry expires
|
|
11059
|
-
* @private
|
|
11060
11054
|
* @returns {void}
|
|
11061
11055
|
*/
|
|
11062
11056
|
}, {
|
|
@@ -11085,7 +11079,6 @@ var Cache = /*#__PURE__*/function () {
|
|
|
11085
11079
|
/**
|
|
11086
11080
|
* Delete a cache entry
|
|
11087
11081
|
* @param {string} key
|
|
11088
|
-
* @private
|
|
11089
11082
|
* @returns {void}
|
|
11090
11083
|
*/
|
|
11091
11084
|
}, {
|
|
@@ -12005,7 +11998,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
12005
11998
|
|
|
12006
11999
|
|
|
12007
12000
|
|
|
12008
|
-
var version = '5.0.
|
|
12001
|
+
var version = '5.0.1-beta';
|
|
12009
12002
|
/* harmony default export */ __webpack_exports__["default"] = (version);
|
|
12010
12003
|
|
|
12011
12004
|
/***/ }),
|