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