@schibsted/account-sdk-browser 5.0.0-beta.1 → 5.0.0-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schibsted/account-sdk-browser",
3
- "version": "5.0.0-beta.1",
3
+ "version": "5.0.0-beta.2",
4
4
  "description": "Schibsted account SDK for browsers",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/identity.d.ts CHANGED
@@ -28,7 +28,8 @@ export class Identity extends TinyEmitter {
28
28
  _sessionInitiatedSent: boolean;
29
29
  window: any;
30
30
  clientId: string;
31
- cache: any;
31
+ sessionStorageCache: any;
32
+ localStorageCache: any;
32
33
  redirectUri: string;
33
34
  env: string;
34
35
  log: Function;
@@ -36,6 +37,34 @@ export class Identity extends TinyEmitter {
36
37
  _sessionDomain: string;
37
38
  _enableSessionCaching: boolean;
38
39
  _session: {};
40
+
41
+ /**
42
+ * Read tabId from session storage
43
+ * @returns {number}
44
+ * @private
45
+ */
46
+ private _getTabId;
47
+ /**
48
+ * Checks if getting session is blocked
49
+ * @private
50
+ *
51
+ * @returns {boolean|void}
52
+ */
53
+ private _isSessionCallBlocked;
54
+ /**
55
+ * Block calls to get session
56
+ * @private
57
+ *
58
+ * @returns {void}
59
+ */
60
+ private _blockSessionCall;
61
+ /**
62
+ * Unblocks calls to get session
63
+ * @private
64
+ *
65
+ * @returns {void}
66
+ */
67
+ private _unblockSessionCall;
39
68
  /**
40
69
  * Set SPiD server URL
41
70
  * @private
package/src/identity.js CHANGED
@@ -219,9 +219,9 @@ export class Identity extends EventEmitter {
219
219
  */
220
220
  _getTabId() {
221
221
  if (this._enableSessionCaching) {
222
- const tabId = this.cache.get(TAB_ID_KEY);
222
+ const tabId = this.sessionStorageCache.get(TAB_ID_KEY);
223
223
  if (!tabId) {
224
- this.cache.set(TAB_ID_KEY, TAB_ID, TAB_ID_TTL);
224
+ this.sessionStorageCache.set(TAB_ID_KEY, TAB_ID, TAB_ID_TTL);
225
225
  return TAB_ID;
226
226
  }
227
227
 
@@ -589,7 +589,7 @@ export class Identity extends EventEmitter {
589
589
  }
590
590
  let sessionData = null;
591
591
  try {
592
- sessionData = await this._sessionService.get('/v2/session');
592
+ sessionData = await this._sessionService.get('/v2/session', {tabId: this._getTabId()});
593
593
  } catch (err) {
594
594
  if (err && err.code === 400 && this._enableSessionCaching) {
595
595
  const expiresIn = 1000 * (err.expiresIn || 300);
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.0-beta.1';
4
+ const version = '5.0.0-beta.2';
5
5
  export default version;