@schibsted/account-sdk-browser 4.8.5 → 4.8.6-beta
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 +6725 -6693
- 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 +6777 -6745
- 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 +6816 -6784
- package/es5/index.js.map +1 -1
- package/es5/index.min.js +1 -1
- package/es5/index.min.js.map +1 -1
- package/package.json +1 -1
- package/src/identity.d.ts +5 -0
- package/src/identity.js +26 -3
package/package.json
CHANGED
package/src/identity.d.ts
CHANGED
|
@@ -553,6 +553,11 @@ export type HasSessionSuccessResponse = {
|
|
|
553
553
|
* - (Only for connected users)
|
|
554
554
|
*/
|
|
555
555
|
defaultAgreementAccepted: boolean;
|
|
556
|
+
} | {
|
|
557
|
+
/**
|
|
558
|
+
* Used for expiring session in Safari browser to indicate redirection need
|
|
559
|
+
*/
|
|
560
|
+
redirectURL: string;
|
|
556
561
|
};
|
|
557
562
|
export type HasSessionFailureResponse = {
|
|
558
563
|
error: {
|
package/src/identity.js
CHANGED
|
@@ -489,6 +489,18 @@ export class Identity extends EventEmitter {
|
|
|
489
489
|
this._session = sessionData;
|
|
490
490
|
return sessionData;
|
|
491
491
|
};
|
|
492
|
+
const _checkRedirectionNeed = (sessionData={})=>{
|
|
493
|
+
const sessionDataKeys = Object.keys(sessionData);
|
|
494
|
+
|
|
495
|
+
const isRedirectNeeded = sessionDataKeys.length === 1 &&
|
|
496
|
+
sessionDataKeys[0] === 'redirectURL';
|
|
497
|
+
|
|
498
|
+
if(isRedirectNeeded && !isUrl(sessionData.redirectURL)){
|
|
499
|
+
throw new SDKError('Session refresh url is not valid');
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
return isRedirectNeeded;
|
|
503
|
+
}
|
|
492
504
|
const _getSession = async () => {
|
|
493
505
|
if (this._enableSessionCaching) {
|
|
494
506
|
// Try to resolve from cache (it has a TTL)
|
|
@@ -508,10 +520,19 @@ export class Identity extends EventEmitter {
|
|
|
508
520
|
throw err;
|
|
509
521
|
}
|
|
510
522
|
|
|
511
|
-
if
|
|
512
|
-
|
|
513
|
-
|
|
523
|
+
if(sessionData){
|
|
524
|
+
// for expiring session and safari browser do full page redirect to gain new session
|
|
525
|
+
if(_checkRedirectionNeed(sessionData)){
|
|
526
|
+
window.location.replace(sessionData.redirectURL);
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
if (this._enableSessionCaching) {
|
|
531
|
+
const expiresIn = 1000 * (sessionData.expiresIn || 300);
|
|
532
|
+
this.cache.set(HAS_SESSION_CACHE_KEY, sessionData, expiresIn);
|
|
533
|
+
}
|
|
514
534
|
}
|
|
535
|
+
|
|
515
536
|
return _postProcess(sessionData);
|
|
516
537
|
};
|
|
517
538
|
this._hasSessionInProgress = _getSession()
|
|
@@ -629,6 +650,8 @@ export class Identity extends EventEmitter {
|
|
|
629
650
|
* meaning the same user's ID will differ between merchants.
|
|
630
651
|
* Additionally, this identifier is bound to the external party provided as argument.
|
|
631
652
|
*
|
|
653
|
+
* @param {string} externalParty
|
|
654
|
+
* @param {string|null} optionalSuffix
|
|
632
655
|
* @description This function calls {@link Identity#hasSession} internally and thus has the side
|
|
633
656
|
* effect that it might perform an auto-login on the user
|
|
634
657
|
* @throws {SDKError} If the `pairId` is missing in user session.
|