@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/global.js
CHANGED
|
@@ -1865,7 +1865,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
1865
1865
|
* `password` (will force password confirmation, even if user is already logged in), `eid`. Those values might
|
|
1866
1866
|
* be mixed as space-separated string. To make sure that user has authenticated with 2FA you need
|
|
1867
1867
|
* to verify AMR (Authentication Methods References) claim in ID token.
|
|
1868
|
-
* Might also be used to ensure additional acr (sms, otp) for already logged
|
|
1868
|
+
* Might also be used to ensure additional acr (sms, otp) for already logged-in users.
|
|
1869
1869
|
* Supported value is also 'otp-email' means one time password using email.
|
|
1870
1870
|
* @property {string} [scope] - The OAuth scopes for the tokens. This is a list of
|
|
1871
1871
|
* scopes, separated by space. If the list of scopes contains `openid`, the generated tokens
|
|
@@ -1899,7 +1899,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
1899
1899
|
* `password` (will force password confirmation, even if user is already logged in). Those values might
|
|
1900
1900
|
* be mixed as space-separated string. To make sure that user has authenticated with 2FA you need
|
|
1901
1901
|
* to verify AMR (Authentication Methods References) claim in ID token.
|
|
1902
|
-
* Might also be used to ensure additional acr (sms, otp) for already logged
|
|
1902
|
+
* Might also be used to ensure additional acr (sms, otp) for already logged-in users.
|
|
1903
1903
|
* Supported value is also 'otp-email' means one time password using email.
|
|
1904
1904
|
* @property {string} [scope] - The OAuth scopes for the tokens. This is a list of
|
|
1905
1905
|
* scopes, separated by space. If the list of scopes contains `openid`, the generated tokens
|
|
@@ -1973,7 +1973,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
1973
1973
|
|
|
1974
1974
|
/**
|
|
1975
1975
|
* @typedef {object} SimplifiedLoginData
|
|
1976
|
-
* @property {string} identifier - Deprecated: User UUID, to be
|
|
1976
|
+
* @property {string} identifier - Deprecated: User UUID, to be as `loginHint` for {@link Identity#login}
|
|
1977
1977
|
* @property {string} display_text - Human-readable user identifier
|
|
1978
1978
|
* @property {string} client_name - Client name
|
|
1979
1979
|
*/
|
|
@@ -1985,7 +1985,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
1985
1985
|
|
|
1986
1986
|
var HAS_SESSION_CACHE_KEY = 'hasSession-cache';
|
|
1987
1987
|
var SESSION_CALL_BLOCKED_CACHE_KEY = 'sessionCallBlocked-cache';
|
|
1988
|
-
var SESSION_CALL_BLOCKED_TTL = 1000 *
|
|
1988
|
+
var SESSION_CALL_BLOCKED_TTL = 1000 * 30;
|
|
1989
1989
|
var TAB_ID_KEY = 'tab-id-cache';
|
|
1990
1990
|
var TAB_ID = Math.floor(Math.random() * 100000);
|
|
1991
1991
|
var TAB_ID_TTL = 1000 * 60 * 60 * 24 * 30;
|
|
@@ -1994,7 +1994,7 @@ var globalWindow = function globalWindow() {
|
|
|
1994
1994
|
};
|
|
1995
1995
|
|
|
1996
1996
|
/**
|
|
1997
|
-
* Provides Identity
|
|
1997
|
+
* Provides Identity functionality to a web page
|
|
1998
1998
|
*/
|
|
1999
1999
|
var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
2000
2000
|
_inherits(Identity, _EventEmitter);
|
|
@@ -2030,23 +2030,20 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
2030
2030
|
Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["assert"])(!redirectUri || Object(_validate_js__WEBPACK_IMPORTED_MODULE_55__["isUrl"])(redirectUri), 'redirectUri parameter is invalid');
|
|
2031
2031
|
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');
|
|
2032
2032
|
_spidTalk_js__WEBPACK_IMPORTED_MODULE_64__["emulate"](window);
|
|
2033
|
+
|
|
2034
|
+
// Internal hack: set as false to always refresh from hasSession
|
|
2035
|
+
_this._enableSessionCaching = true;
|
|
2033
2036
|
_this._sessionInitiatedSent = false;
|
|
2034
2037
|
_this.window = window;
|
|
2035
2038
|
_this.clientId = clientId;
|
|
2036
|
-
_this.sessionStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](
|
|
2037
|
-
|
|
2038
|
-
});
|
|
2039
|
-
_this.localStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](function () {
|
|
2040
|
-
return _this.window && _this.window.localStorage;
|
|
2041
|
-
});
|
|
2039
|
+
_this.sessionStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](_this.window && _this.window.sessionStorage);
|
|
2040
|
+
_this.localStorageCache = new _cache_js__WEBPACK_IMPORTED_MODULE_60__["default"](_this.window && _this.window.localStorage);
|
|
2042
2041
|
_this.redirectUri = redirectUri;
|
|
2043
2042
|
_this.env = env;
|
|
2044
2043
|
_this.log = log;
|
|
2045
2044
|
_this.callbackBeforeRedirect = callbackBeforeRedirect;
|
|
2046
2045
|
_this._sessionDomain = sessionDomain;
|
|
2047
|
-
|
|
2048
|
-
// Internal hack: set to false to always refresh from hassession
|
|
2049
|
-
_this._enableSessionCaching = true;
|
|
2046
|
+
_this._tabId = _this._getTabId();
|
|
2050
2047
|
|
|
2051
2048
|
// Old session
|
|
2052
2049
|
_this._session = {};
|
|
@@ -2055,12 +2052,12 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
2055
2052
|
_this._setBffServerUrl(env);
|
|
2056
2053
|
_this._setOauthServerUrl(env);
|
|
2057
2054
|
_this._setGlobalSessionServiceUrl(env);
|
|
2058
|
-
_this.
|
|
2055
|
+
_this._unblockSessionCallByTab();
|
|
2059
2056
|
return _this;
|
|
2060
2057
|
}
|
|
2061
2058
|
|
|
2062
2059
|
/**
|
|
2063
|
-
* Read tabId from session storage
|
|
2060
|
+
* Read tabId from session storage if possible, otherwise save tabId to session storage and return it
|
|
2064
2061
|
* @returns {number}
|
|
2065
2062
|
* @private
|
|
2066
2063
|
*/
|
|
@@ -2075,13 +2072,13 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
2075
2072
|
}
|
|
2076
2073
|
return tabId;
|
|
2077
2074
|
}
|
|
2075
|
+
return TAB_ID;
|
|
2078
2076
|
}
|
|
2079
2077
|
|
|
2080
2078
|
/**
|
|
2081
|
-
* Checks if
|
|
2079
|
+
* Checks if calling GET session is blocked
|
|
2082
2080
|
* @private
|
|
2083
|
-
*
|
|
2084
|
-
* @returns {boolean|void}
|
|
2081
|
+
* @returns {number|null}
|
|
2085
2082
|
*/
|
|
2086
2083
|
}, {
|
|
2087
2084
|
key: "_isSessionCallBlocked",
|
|
@@ -2090,28 +2087,27 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
2090
2087
|
}
|
|
2091
2088
|
|
|
2092
2089
|
/**
|
|
2093
|
-
* Block calls to get session
|
|
2090
|
+
* 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
|
|
2094
2091
|
* @private
|
|
2095
|
-
*
|
|
2096
2092
|
* @returns {void}
|
|
2097
2093
|
*/
|
|
2098
2094
|
}, {
|
|
2099
2095
|
key: "_blockSessionCall",
|
|
2100
2096
|
value: function _blockSessionCall() {
|
|
2101
|
-
|
|
2102
|
-
this.localStorageCache.set(SESSION_CALL_BLOCKED_CACHE_KEY, SESSION_CALL_BLOCKED, SESSION_CALL_BLOCKED_TTL);
|
|
2097
|
+
this.localStorageCache.set(SESSION_CALL_BLOCKED_CACHE_KEY, this._tabId, SESSION_CALL_BLOCKED_TTL);
|
|
2103
2098
|
}
|
|
2104
2099
|
|
|
2105
2100
|
/**
|
|
2106
|
-
* Unblocks calls to get session
|
|
2101
|
+
* Unblocks calls to get session if the lock was put by the same tab
|
|
2107
2102
|
* @private
|
|
2108
|
-
*
|
|
2109
2103
|
* @returns {void}
|
|
2110
2104
|
*/
|
|
2111
2105
|
}, {
|
|
2112
|
-
key: "
|
|
2113
|
-
value: function
|
|
2114
|
-
this.
|
|
2106
|
+
key: "_unblockSessionCallByTab",
|
|
2107
|
+
value: function _unblockSessionCallByTab() {
|
|
2108
|
+
if (this._isSessionCallBlocked() === this._tabId) {
|
|
2109
|
+
this.localStorageCache.delete(SESSION_CALL_BLOCKED_CACHE_KEY);
|
|
2110
|
+
}
|
|
2115
2111
|
}
|
|
2116
2112
|
|
|
2117
2113
|
/**
|
|
@@ -2218,7 +2214,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
2218
2214
|
}
|
|
2219
2215
|
|
|
2220
2216
|
/**
|
|
2221
|
-
* Emits the relevant events based on the previous and new reply from
|
|
2217
|
+
* Emits the relevant events based on the previous and new reply from {@link Identity#hasSession}
|
|
2222
2218
|
* @private
|
|
2223
2219
|
* @param {object} previous
|
|
2224
2220
|
* @param {object} current
|
|
@@ -2302,7 +2298,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
2302
2298
|
}
|
|
2303
2299
|
|
|
2304
2300
|
/**
|
|
2305
|
-
* Set the Varnish cookie (`SP_ID`) when hasSession
|
|
2301
|
+
* Set the Varnish cookie (`SP_ID`) when {@link Identity#hasSession} is called. Note that most browsers require
|
|
2306
2302
|
* that you are on a "real domain" for this to work — so, **not** `localhost`
|
|
2307
2303
|
* @param {object} [options]
|
|
2308
2304
|
* @param {number} [options.expiresIn] Override this to set number of seconds before the varnish
|
|
@@ -2466,7 +2462,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
2466
2462
|
_context.prev = 5;
|
|
2467
2463
|
_context.next = 8;
|
|
2468
2464
|
return _this2._sessionService.get('/v2/session', {
|
|
2469
|
-
tabId: _this2.
|
|
2465
|
+
tabId: _this2._tabId
|
|
2470
2466
|
});
|
|
2471
2467
|
case 8:
|
|
2472
2468
|
sessionData = _context.sent;
|
|
@@ -2666,7 +2662,7 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
2666
2662
|
* @description This function calls {@link Identity#hasSession} internally and thus has the side
|
|
2667
2663
|
* effect that it might perform an auto-login on the user
|
|
2668
2664
|
* @throws {SDKError} If the user isn't connected to the merchant
|
|
2669
|
-
* @return {
|
|
2665
|
+
* @return {number} The `userId` field (not to be confused with the `uuid`)
|
|
2670
2666
|
*/
|
|
2671
2667
|
}, {
|
|
2672
2668
|
key: "getUserId",
|
|
@@ -11048,7 +11044,6 @@ var Cache = /*#__PURE__*/function () {
|
|
|
11048
11044
|
/**
|
|
11049
11045
|
* Get a value from cache (checks that the object has not expired)
|
|
11050
11046
|
* @param {string} key
|
|
11051
|
-
* @private
|
|
11052
11047
|
* @returns {*} - The value if it exists, otherwise null
|
|
11053
11048
|
*/
|
|
11054
11049
|
_createClass(Cache, [{
|
|
@@ -11084,7 +11079,6 @@ var Cache = /*#__PURE__*/function () {
|
|
|
11084
11079
|
* @param {string} key
|
|
11085
11080
|
* @param {*} value
|
|
11086
11081
|
* @param {Number} expiresIn - Value in milliseconds until the entry expires
|
|
11087
|
-
* @private
|
|
11088
11082
|
* @returns {void}
|
|
11089
11083
|
*/
|
|
11090
11084
|
}, {
|
|
@@ -11113,7 +11107,6 @@ var Cache = /*#__PURE__*/function () {
|
|
|
11113
11107
|
/**
|
|
11114
11108
|
* Delete a cache entry
|
|
11115
11109
|
* @param {string} key
|
|
11116
|
-
* @private
|
|
11117
11110
|
* @returns {void}
|
|
11118
11111
|
*/
|
|
11119
11112
|
}, {
|
|
@@ -12033,7 +12026,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
12033
12026
|
|
|
12034
12027
|
|
|
12035
12028
|
|
|
12036
|
-
var version = '5.0.
|
|
12029
|
+
var version = '5.0.1-beta';
|
|
12037
12030
|
/* harmony default export */ __webpack_exports__["default"] = (version);
|
|
12038
12031
|
|
|
12039
12032
|
/***/ }),
|