@schibsted/account-sdk-browser 5.0.0-beta.2 → 5.0.1
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 +20 -17
- 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 +20 -17
- 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 +20 -17
- 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 +1 -2
- package/src/identity.js +23 -18
- package/src/version.js +1 -1
package/package.json
CHANGED
package/src/identity.d.ts
CHANGED
package/src/identity.js
CHANGED
|
@@ -189,8 +189,7 @@ export class Identity extends EventEmitter {
|
|
|
189
189
|
this._sessionInitiatedSent = false;
|
|
190
190
|
this.window = window;
|
|
191
191
|
this.clientId = clientId;
|
|
192
|
-
this.
|
|
193
|
-
this.localStorageCache = new Cache(() => this.window && this.window.localStorage);
|
|
192
|
+
this.cache = new Cache(() => this.window && this.window.sessionStorage);
|
|
194
193
|
this.redirectUri = redirectUri;
|
|
195
194
|
this.env = env;
|
|
196
195
|
this.log = log;
|
|
@@ -219,9 +218,9 @@ export class Identity extends EventEmitter {
|
|
|
219
218
|
*/
|
|
220
219
|
_getTabId() {
|
|
221
220
|
if (this._enableSessionCaching) {
|
|
222
|
-
const tabId = this.
|
|
221
|
+
const tabId = this.cache.get(TAB_ID_KEY);
|
|
223
222
|
if (!tabId) {
|
|
224
|
-
this.
|
|
223
|
+
this.cache.set(TAB_ID_KEY, TAB_ID, TAB_ID_TTL);
|
|
225
224
|
return TAB_ID;
|
|
226
225
|
}
|
|
227
226
|
|
|
@@ -236,7 +235,9 @@ export class Identity extends EventEmitter {
|
|
|
236
235
|
* @returns {boolean|void}
|
|
237
236
|
*/
|
|
238
237
|
_isSessionCallBlocked(){
|
|
239
|
-
|
|
238
|
+
if (this._enableSessionCaching) {
|
|
239
|
+
return this.cache.get(SESSION_CALL_BLOCKED_CACHE_KEY);
|
|
240
|
+
}
|
|
240
241
|
}
|
|
241
242
|
|
|
242
243
|
/**
|
|
@@ -246,13 +247,15 @@ export class Identity extends EventEmitter {
|
|
|
246
247
|
* @returns {void}
|
|
247
248
|
*/
|
|
248
249
|
_blockSessionCall(){
|
|
249
|
-
|
|
250
|
+
if (this._enableSessionCaching) {
|
|
251
|
+
const SESSION_CALL_BLOCKED = true;
|
|
250
252
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
253
|
+
this.cache.set(
|
|
254
|
+
SESSION_CALL_BLOCKED_CACHE_KEY,
|
|
255
|
+
SESSION_CALL_BLOCKED,
|
|
256
|
+
SESSION_CALL_BLOCKED_TTL
|
|
257
|
+
);
|
|
258
|
+
}
|
|
256
259
|
}
|
|
257
260
|
|
|
258
261
|
/**
|
|
@@ -262,7 +265,9 @@ export class Identity extends EventEmitter {
|
|
|
262
265
|
* @returns {void}
|
|
263
266
|
*/
|
|
264
267
|
_unblockSessionCall(){
|
|
265
|
-
this.
|
|
268
|
+
if (this._enableSessionCaching) {
|
|
269
|
+
this.cache.delete(SESSION_CALL_BLOCKED_CACHE_KEY);
|
|
270
|
+
}
|
|
266
271
|
}
|
|
267
272
|
|
|
268
273
|
/**
|
|
@@ -582,7 +587,7 @@ export class Identity extends EventEmitter {
|
|
|
582
587
|
const _getSession = async () => {
|
|
583
588
|
if (this._enableSessionCaching) {
|
|
584
589
|
// Try to resolve from cache (it has a TTL)
|
|
585
|
-
let cachedSession = this.
|
|
590
|
+
let cachedSession = this.cache.get(HAS_SESSION_CACHE_KEY);
|
|
586
591
|
if (cachedSession) {
|
|
587
592
|
return _postProcess(cachedSession);
|
|
588
593
|
}
|
|
@@ -593,7 +598,7 @@ export class Identity extends EventEmitter {
|
|
|
593
598
|
} catch (err) {
|
|
594
599
|
if (err && err.code === 400 && this._enableSessionCaching) {
|
|
595
600
|
const expiresIn = 1000 * (err.expiresIn || 300);
|
|
596
|
-
this.
|
|
601
|
+
this.cache.set(HAS_SESSION_CACHE_KEY, { error: err }, expiresIn);
|
|
597
602
|
}
|
|
598
603
|
throw err;
|
|
599
604
|
}
|
|
@@ -610,7 +615,7 @@ export class Identity extends EventEmitter {
|
|
|
610
615
|
|
|
611
616
|
if (this._enableSessionCaching) {
|
|
612
617
|
const expiresIn = 1000 * (sessionData.expiresIn || 300);
|
|
613
|
-
this.
|
|
618
|
+
this.cache.set(HAS_SESSION_CACHE_KEY, sessionData, expiresIn);
|
|
614
619
|
}
|
|
615
620
|
}
|
|
616
621
|
|
|
@@ -658,7 +663,7 @@ export class Identity extends EventEmitter {
|
|
|
658
663
|
* @returns {void}
|
|
659
664
|
*/
|
|
660
665
|
clearCachedUserSession() {
|
|
661
|
-
this.
|
|
666
|
+
this.cache.delete(HAS_SESSION_CACHE_KEY);
|
|
662
667
|
}
|
|
663
668
|
|
|
664
669
|
/**
|
|
@@ -869,7 +874,7 @@ export class Identity extends EventEmitter {
|
|
|
869
874
|
prompt = 'select_account'
|
|
870
875
|
}) {
|
|
871
876
|
this._closePopup();
|
|
872
|
-
this.
|
|
877
|
+
this.cache.delete(HAS_SESSION_CACHE_KEY);
|
|
873
878
|
const url = this.loginUrl({
|
|
874
879
|
state,
|
|
875
880
|
acrValues,
|
|
@@ -918,7 +923,7 @@ export class Identity extends EventEmitter {
|
|
|
918
923
|
* @return {void}
|
|
919
924
|
*/
|
|
920
925
|
logout(redirectUri = this.redirectUri) {
|
|
921
|
-
this.
|
|
926
|
+
this.cache.delete(HAS_SESSION_CACHE_KEY);
|
|
922
927
|
this._maybeClearVarnishCookie();
|
|
923
928
|
this.emit('logout');
|
|
924
929
|
this.window.location.href = this.logoutUrl(redirectUri);
|
package/src/version.js
CHANGED