@@ -45,6 +45,7 @@ import {
45
45
DEFAULT_REQUEST ,
46
46
BrowserConstants ,
47
47
iFrameRenewalPolicies ,
48
+ INTERACTION_TYPE ,
48
49
} from "../utils/BrowserConstants.js" ;
49
50
import * as BrowserUtils from "../utils/BrowserUtils.js" ;
50
51
import { RedirectRequest } from "../request/RedirectRequest.js" ;
@@ -443,6 +444,16 @@ export class StandardController implements IController {
443
444
return null ;
444
445
}
445
446
447
+ const interactionType =
448
+ this . browserStorage . getInteractionInProgress ( ) ?. type ;
449
+ if ( interactionType === INTERACTION_TYPE . SIGNOUT ) {
450
+ this . logger . verbose (
451
+ "handleRedirectPromise removing interaction_in_progress flag and returning null after sign-out"
452
+ ) ;
453
+ this . browserStorage . setInteractionInProgress ( false ) ;
454
+ return Promise . resolve ( null ) ;
455
+ }
456
+
446
457
const loggedInAccounts = this . getAllAccounts ( ) ;
447
458
const platformBrokerRequest : NativeTokenRequest | null =
448
459
this . browserStorage . getCachedNativeRequest ( ) ;
@@ -455,63 +466,68 @@ export class StandardController implements IController {
455
466
) &&
456
467
this . nativeExtensionProvider &&
457
468
! hash ;
458
- let rootMeasurement = this . performanceClient . startMeasurement (
459
- PerformanceEvents . AcquireTokenRedirect ,
460
- platformBrokerRequest ?. correlationId || ""
461
- ) ;
469
+ let rootMeasurement : InProgressPerformanceEvent ;
462
470
this . eventHandler . emitEvent (
463
471
EventType . HANDLE_REDIRECT_START ,
464
472
InteractionType . Redirect
465
473
) ;
466
474
467
475
let redirectResponse : Promise < AuthenticationResult | null > ;
468
- if ( useNative && this . nativeExtensionProvider ) {
469
- this . logger . trace (
470
- "handleRedirectPromise - acquiring token from native platform"
471
- ) ;
472
- const nativeClient = new NativeInteractionClient (
473
- this . config ,
474
- this . browserStorage ,
475
- this . browserCrypto ,
476
- this . logger ,
477
- this . eventHandler ,
478
- this . navigationClient ,
479
- ApiId . handleRedirectPromise ,
480
- this . performanceClient ,
481
- this . nativeExtensionProvider ,
482
- platformBrokerRequest . accountId ,
483
- this . nativeInternalStorage ,
484
- platformBrokerRequest . correlationId
485
- ) ;
476
+ try {
477
+ if ( useNative && this . nativeExtensionProvider ) {
478
+ rootMeasurement = this . performanceClient . startMeasurement (
479
+ PerformanceEvents . AcquireTokenRedirect ,
480
+ platformBrokerRequest ?. correlationId || ""
481
+ ) ;
482
+ this . logger . trace (
483
+ "handleRedirectPromise - acquiring token from native platform"
484
+ ) ;
485
+ const nativeClient = new NativeInteractionClient (
486
+ this . config ,
487
+ this . browserStorage ,
488
+ this . browserCrypto ,
489
+ this . logger ,
490
+ this . eventHandler ,
491
+ this . navigationClient ,
492
+ ApiId . handleRedirectPromise ,
493
+ this . performanceClient ,
494
+ this . nativeExtensionProvider ,
495
+ platformBrokerRequest . accountId ,
496
+ this . nativeInternalStorage ,
497
+ platformBrokerRequest . correlationId
498
+ ) ;
486
499
487
- redirectResponse = invokeAsync (
488
- nativeClient . handleRedirectPromise . bind ( nativeClient ) ,
489
- PerformanceEvents . HandleNativeRedirectPromiseMeasurement ,
490
- this . logger ,
491
- this . performanceClient ,
492
- rootMeasurement . event . correlationId
493
- ) ( this . performanceClient , rootMeasurement . event . correlationId ) ;
494
- } else {
495
- const [ standardRequest , codeVerifier ] =
496
- this . browserStorage . getCachedRequest ( ) ;
497
- const correlationId = standardRequest . correlationId ;
498
- // Reset rootMeasurement now that we have correlationId
499
- rootMeasurement . discard ( ) ;
500
- rootMeasurement = this . performanceClient . startMeasurement (
501
- PerformanceEvents . AcquireTokenRedirect ,
502
- correlationId
503
- ) ;
504
- this . logger . trace (
505
- "handleRedirectPromise - acquiring token from web flow"
506
- ) ;
507
- const redirectClient = this . createRedirectClient ( correlationId ) ;
508
- redirectResponse = invokeAsync (
509
- redirectClient . handleRedirectPromise . bind ( redirectClient ) ,
510
- PerformanceEvents . HandleRedirectPromiseMeasurement ,
511
- this . logger ,
512
- this . performanceClient ,
513
- rootMeasurement . event . correlationId
514
- ) ( hash , standardRequest , codeVerifier , rootMeasurement ) ;
500
+ redirectResponse = invokeAsync (
501
+ nativeClient . handleRedirectPromise . bind ( nativeClient ) ,
502
+ PerformanceEvents . HandleNativeRedirectPromiseMeasurement ,
503
+ this . logger ,
504
+ this . performanceClient ,
505
+ rootMeasurement . event . correlationId
506
+ ) ( this . performanceClient , rootMeasurement . event . correlationId ) ;
507
+ } else {
508
+ const [ standardRequest , codeVerifier ] =
509
+ this . browserStorage . getCachedRequest ( ) ;
510
+ const correlationId = standardRequest . correlationId ;
511
+ // Reset rootMeasurement now that we have correlationId
512
+ rootMeasurement = this . performanceClient . startMeasurement (
513
+ PerformanceEvents . AcquireTokenRedirect ,
514
+ correlationId
515
+ ) ;
516
+ this . logger . trace (
517
+ "handleRedirectPromise - acquiring token from web flow"
518
+ ) ;
519
+ const redirectClient = this . createRedirectClient ( correlationId ) ;
520
+ redirectResponse = invokeAsync (
521
+ redirectClient . handleRedirectPromise . bind ( redirectClient ) ,
522
+ PerformanceEvents . HandleRedirectPromiseMeasurement ,
523
+ this . logger ,
524
+ this . performanceClient ,
525
+ rootMeasurement . event . correlationId
526
+ ) ( hash , standardRequest , codeVerifier , rootMeasurement ) ;
527
+ }
528
+ } catch ( e ) {
529
+ this . browserStorage . resetRequestCache ( ) ;
530
+ throw e ;
515
531
}
516
532
517
533
return redirectResponse
@@ -657,7 +673,10 @@ export class StandardController implements IController {
657
673
const isLoggedIn = this . getAllAccounts ( ) . length > 0 ;
658
674
try {
659
675
BrowserUtils . redirectPreflightCheck ( this . initialized , this . config ) ;
660
- this . browserStorage . setInteractionInProgress ( true ) ;
676
+ this . browserStorage . setInteractionInProgress (
677
+ true ,
678
+ INTERACTION_TYPE . SIGNIN
679
+ ) ;
661
680
662
681
if ( isLoggedIn ) {
663
682
this . eventHandler . emitEvent (
@@ -768,7 +787,10 @@ export class StandardController implements IController {
768
787
try {
769
788
this . logger . verbose ( "acquireTokenPopup called" , correlationId ) ;
770
789
preflightCheck ( this . initialized , atPopupMeasurement ) ;
771
- this . browserStorage . setInteractionInProgress ( true ) ;
790
+ this . browserStorage . setInteractionInProgress (
791
+ true ,
792
+ INTERACTION_TYPE . SIGNIN
793
+ ) ;
772
794
} catch ( e ) {
773
795
// Since this function is syncronous we need to reject
774
796
return Promise . reject ( e ) ;
@@ -1349,7 +1371,10 @@ export class StandardController implements IController {
1349
1371
async logoutRedirect ( logoutRequest ?: EndSessionRequest ) : Promise < void > {
1350
1372
const correlationId = this . getRequestCorrelationId ( logoutRequest ) ;
1351
1373
BrowserUtils . redirectPreflightCheck ( this . initialized , this . config ) ;
1352
- this . browserStorage . setInteractionInProgress ( true ) ;
1374
+ this . browserStorage . setInteractionInProgress (
1375
+ true ,
1376
+ INTERACTION_TYPE . SIGNOUT
1377
+ ) ;
1353
1378
1354
1379
const redirectClient = this . createRedirectClient ( correlationId ) ;
1355
1380
return redirectClient . logout ( logoutRequest ) ;
@@ -1363,7 +1388,10 @@ export class StandardController implements IController {
1363
1388
try {
1364
1389
const correlationId = this . getRequestCorrelationId ( logoutRequest ) ;
1365
1390
BrowserUtils . preflightCheck ( this . initialized ) ;
1366
- this . browserStorage . setInteractionInProgress ( true ) ;
1391
+ this . browserStorage . setInteractionInProgress (
1392
+ true ,
1393
+ INTERACTION_TYPE . SIGNOUT
1394
+ ) ;
1367
1395
1368
1396
const popupClient = this . createPopupClient ( correlationId ) ;
1369
1397
return popupClient . logout ( logoutRequest ) . finally ( ( ) => {
0 commit comments