@schibsted/account-sdk-browser 4.8.5 → 4.8.6-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 +637 -607
- 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 +610 -580
- 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 +642 -612
- 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 +5 -0
- package/src/identity.js +26 -3
- package/src/version.js +1 -1
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,14 @@ 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
|
+
return isRedirectNeeded;
|
|
499
|
+
}
|
|
492
500
|
const _getSession = async () => {
|
|
493
501
|
if (this._enableSessionCaching) {
|
|
494
502
|
// Try to resolve from cache (it has a TTL)
|
|
@@ -508,10 +516,23 @@ export class Identity extends EventEmitter {
|
|
|
508
516
|
throw err;
|
|
509
517
|
}
|
|
510
518
|
|
|
511
|
-
if
|
|
512
|
-
|
|
513
|
-
|
|
519
|
+
if(sessionData){
|
|
520
|
+
// for expiring session and safari browser do full page redirect to gain new session
|
|
521
|
+
if(_checkRedirectionNeed(sessionData)){
|
|
522
|
+
const client_sdrn = `sdrn:${NAMESPACE[this.env]}:client:${this.clientId}`;
|
|
523
|
+
const redirectBackUrl = this.redirectUri.substring(0 , this.redirectUri.lastIndexOf('/'));
|
|
524
|
+
const params = { redirect_uri: redirectBackUrl, client_sdrn: client_sdrn};
|
|
525
|
+
this.emit('redirectToSessionService');
|
|
526
|
+
this.window.location.href = this._sessionService.makeUrl(sessionData.redirectURL.substring(sessionData.redirectURL.lastIndexOf('/')), params);
|
|
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.
|
package/src/version.js
CHANGED