@schibsted/account-sdk-browser 5.0.1-beta.4 → 5.0.1-beta.6
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 +7 -14
- 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 +7 -14
- 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 +7 -14
- 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 -1
- 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/identity.d.ts +2 -3
- package/src/identity.js +6 -19
- package/src/version.js +1 -1
package/package.json
CHANGED
package/src/identity.d.ts
CHANGED
|
@@ -45,9 +45,8 @@ export class Identity extends TinyEmitter {
|
|
|
45
45
|
*/
|
|
46
46
|
private _getTabId;
|
|
47
47
|
/**
|
|
48
|
-
* Checks if calling
|
|
48
|
+
* Checks if calling get session is blocked
|
|
49
49
|
* @private
|
|
50
|
-
* @param {Cache} cache - cache to check
|
|
51
50
|
* @returns {string|null}
|
|
52
51
|
*/
|
|
53
52
|
private _isSessionCallBlocked;
|
|
@@ -62,7 +61,7 @@ export class Identity extends TinyEmitter {
|
|
|
62
61
|
* @private
|
|
63
62
|
* @returns {void}
|
|
64
63
|
*/
|
|
65
|
-
private
|
|
64
|
+
private _unblockSessionCall;
|
|
66
65
|
/**
|
|
67
66
|
* Set SPiD server URL
|
|
68
67
|
* @private
|
package/src/identity.js
CHANGED
|
@@ -146,7 +146,7 @@ import version from './version.js';
|
|
|
146
146
|
|
|
147
147
|
const HAS_SESSION_CACHE_KEY = 'hasSession-cache';
|
|
148
148
|
const SESSION_CALL_BLOCKED_CACHE_KEY = 'sessionCallBlocked-cache';
|
|
149
|
-
const SESSION_CALL_BLOCKED_TTL = 1000 *
|
|
149
|
+
const SESSION_CALL_BLOCKED_TTL = 1000 * 15; //set to 15s, to not block calls much longer than the time attempting retries
|
|
150
150
|
|
|
151
151
|
const TAB_ID_KEY = 'tab-id-cache';
|
|
152
152
|
const TAB_ID = Math.floor(Math.random() * 100000)
|
|
@@ -213,7 +213,6 @@ export class Identity extends EventEmitter {
|
|
|
213
213
|
this._setBffServerUrl(env);
|
|
214
214
|
this._setOauthServerUrl(env);
|
|
215
215
|
this._setGlobalSessionServiceUrl(env);
|
|
216
|
-
this._unblockSessionCallByTab();
|
|
217
216
|
}
|
|
218
217
|
|
|
219
218
|
/**
|
|
@@ -237,13 +236,12 @@ export class Identity extends EventEmitter {
|
|
|
237
236
|
}
|
|
238
237
|
|
|
239
238
|
/**
|
|
240
|
-
* Checks if calling GET session is blocked
|
|
239
|
+
* Checks if calling GET session is blocked
|
|
241
240
|
* @private
|
|
242
|
-
* @param {Cache} cache - cache to check
|
|
243
241
|
* @returns {string|null}
|
|
244
242
|
*/
|
|
245
|
-
_isSessionCallBlocked(
|
|
246
|
-
return
|
|
243
|
+
_isSessionCallBlocked() {
|
|
244
|
+
return this.localStorageCache.get(SESSION_CALL_BLOCKED_CACHE_KEY);
|
|
247
245
|
}
|
|
248
246
|
|
|
249
247
|
/**
|
|
@@ -252,14 +250,6 @@ export class Identity extends EventEmitter {
|
|
|
252
250
|
* @returns {void}
|
|
253
251
|
*/
|
|
254
252
|
_blockSessionCall() {
|
|
255
|
-
// session storage block protects against single tab, multiple identity instance concurrency
|
|
256
|
-
this.sessionStorageCache.set(
|
|
257
|
-
SESSION_CALL_BLOCKED_CACHE_KEY,
|
|
258
|
-
this._tabId,
|
|
259
|
-
SESSION_CALL_BLOCKED_TTL
|
|
260
|
-
);
|
|
261
|
-
|
|
262
|
-
// local storage block protects against cross-tab concurrency
|
|
263
253
|
this.localStorageCache.set(
|
|
264
254
|
SESSION_CALL_BLOCKED_CACHE_KEY,
|
|
265
255
|
this._tabId,
|
|
@@ -273,11 +263,9 @@ export class Identity extends EventEmitter {
|
|
|
273
263
|
* @returns {void}
|
|
274
264
|
*/
|
|
275
265
|
_unblockSessionCallByTab() {
|
|
276
|
-
if (this._isSessionCallBlocked(
|
|
266
|
+
if (this._isSessionCallBlocked() === this._tabId) {
|
|
277
267
|
this.localStorageCache.delete(SESSION_CALL_BLOCKED_CACHE_KEY);
|
|
278
268
|
}
|
|
279
|
-
|
|
280
|
-
this.sessionStorageCache.delete(SESSION_CALL_BLOCKED_CACHE_KEY);
|
|
281
269
|
}
|
|
282
270
|
|
|
283
271
|
/**
|
|
@@ -636,7 +624,7 @@ export class Identity extends EventEmitter {
|
|
|
636
624
|
}
|
|
637
625
|
}
|
|
638
626
|
|
|
639
|
-
if (this._isSessionCallBlocked(
|
|
627
|
+
if (this._isSessionCallBlocked()) {
|
|
640
628
|
if (this._session && this._session.userId) {
|
|
641
629
|
return _postProcess(this._session);
|
|
642
630
|
}
|
|
@@ -663,7 +651,6 @@ export class Identity extends EventEmitter {
|
|
|
663
651
|
// Try to call session-service MAX_SESSION_CALL_RETRIES times, waiting up to 1 second each time
|
|
664
652
|
while (retryCount < MAX_SESSION_CALL_RETRIES) {
|
|
665
653
|
retryCount++;
|
|
666
|
-
|
|
667
654
|
const randomWaitingStep = Math.floor(Math.random() * 9); // ignoring waiting times that are too small to matter
|
|
668
655
|
const randomWaitTime = MIN_SESSION_CALL_WAIT_TIME + (randomWaitingStep * 100);
|
|
669
656
|
await new Promise(resolve => setTimeout(resolve, randomWaitTime));
|
package/src/version.js
CHANGED