@schibsted/account-sdk-browser 5.0.1-beta → 5.0.1-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/es5/global.js +35 -30
- 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 +35 -30
- 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 +35 -30
- 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.js +14 -17
- package/src/version.js +1 -1
package/package.json
CHANGED
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;
|
|
149
|
+
const SESSION_CALL_BLOCKED_TTL = 1000 * 30; //set to 30s, the default period for a request timeout
|
|
150
150
|
|
|
151
151
|
const TAB_ID_KEY = 'tab-id-cache';
|
|
152
152
|
const TAB_ID = Math.floor(Math.random() * 100000)
|
|
@@ -193,8 +193,8 @@ export class Identity extends EventEmitter {
|
|
|
193
193
|
this._sessionInitiatedSent = false;
|
|
194
194
|
this.window = window;
|
|
195
195
|
this.clientId = clientId;
|
|
196
|
-
this.sessionStorageCache = new Cache(this.window && this.window.sessionStorage);
|
|
197
|
-
this.localStorageCache = new Cache(this.window && this.window.localStorage);
|
|
196
|
+
this.sessionStorageCache = new Cache(() => this.window && this.window.sessionStorage);
|
|
197
|
+
this.localStorageCache = new Cache(() =>this.window && this.window.localStorage);
|
|
198
198
|
this.redirectUri = redirectUri;
|
|
199
199
|
this.env = env;
|
|
200
200
|
this.log = log;
|
|
@@ -554,11 +554,6 @@ export class Identity extends EventEmitter {
|
|
|
554
554
|
* @return {Promise<HasSessionSuccessResponse|HasSessionFailureResponse>}
|
|
555
555
|
*/
|
|
556
556
|
hasSession() {
|
|
557
|
-
const isSessionCallBlocked = this._isSessionCallBlocked()
|
|
558
|
-
if (isSessionCallBlocked) {
|
|
559
|
-
return this._session;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
557
|
if (this._hasSessionInProgress) {
|
|
563
558
|
return this._hasSessionInProgress;
|
|
564
559
|
}
|
|
@@ -589,8 +584,16 @@ export class Identity extends EventEmitter {
|
|
|
589
584
|
}
|
|
590
585
|
}
|
|
591
586
|
|
|
587
|
+
// Prevent concurrent calls to session-service
|
|
588
|
+
if (this._isSessionCallBlocked()) {
|
|
589
|
+
// Returning data directly, without _postProcess since the data returned is the local copy
|
|
590
|
+
return this._session;
|
|
591
|
+
}
|
|
592
|
+
|
|
592
593
|
let sessionData = null;
|
|
593
594
|
try {
|
|
595
|
+
this._blockSessionCall();
|
|
596
|
+
|
|
594
597
|
sessionData = await this._sessionService.get('/v2/session', {tabId: this._tabId});
|
|
595
598
|
} catch (err) {
|
|
596
599
|
if (err && err.code === 400 && this._enableSessionCaching) {
|
|
@@ -601,13 +604,10 @@ export class Identity extends EventEmitter {
|
|
|
601
604
|
}
|
|
602
605
|
|
|
603
606
|
if (sessionData){
|
|
604
|
-
//
|
|
607
|
+
// For expiring session and Safari browser do full page redirect to get new session
|
|
605
608
|
if(_checkRedirectionNeed(sessionData)){
|
|
606
|
-
this._blockSessionCall();
|
|
607
|
-
|
|
608
609
|
await this.callbackBeforeRedirect();
|
|
609
|
-
|
|
610
|
-
return this._sessionService.makeUrl(sessionData.redirectURL, {tabId: this._getTabId()});
|
|
610
|
+
this.window.location.href = this._sessionService.makeUrl(sessionData.redirectURL, {tabId: this._getTabId()});
|
|
611
611
|
}
|
|
612
612
|
|
|
613
613
|
if (this._enableSessionCaching) {
|
|
@@ -623,10 +623,6 @@ export class Identity extends EventEmitter {
|
|
|
623
623
|
sessionData => {
|
|
624
624
|
this._hasSessionInProgress = false;
|
|
625
625
|
|
|
626
|
-
if (isUrl(sessionData)) {
|
|
627
|
-
return this.window.location.href = sessionData;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
626
|
return sessionData;
|
|
631
627
|
},
|
|
632
628
|
err => {
|
|
@@ -636,6 +632,7 @@ export class Identity extends EventEmitter {
|
|
|
636
632
|
}
|
|
637
633
|
);
|
|
638
634
|
|
|
635
|
+
this._unblockSessionCallByTab();
|
|
639
636
|
return this._hasSessionInProgress;
|
|
640
637
|
}
|
|
641
638
|
|
package/src/version.js
CHANGED