@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schibsted/account-sdk-browser",
3
- "version": "5.0.1-beta.4",
3
+ "version": "5.0.1-beta.6",
4
4
  "description": "Schibsted account SDK for browsers",
5
5
  "main": "index.js",
6
6
  "type": "module",
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 GET session is blocked by a cache storage
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 _unblockSessionCallByTab;
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 * 30; //set to 30s, the default period for a request timeout
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 by a cache storage
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(cache) {
246
- return cache.get(SESSION_CALL_BLOCKED_CACHE_KEY);
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(this.localStorageCache) === this._tabId) {
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(this.sessionStorageCache) || this._isSessionCallBlocked(this.localStorageCache)) {
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
@@ -1,5 +1,5 @@
1
1
  // Automatically generated in 'npm version' by scripts/genversion.js
2
2
 
3
3
  'use strict'
4
- const version = '5.0.1-beta.4';
4
+ const version = '5.0.1-beta.6';
5
5
  export default version;