@@ -287,33 +287,46 @@ export class UserAgentApplication {
287
287
* @param hash
288
288
*/
289
289
public urlContainsHash ( hash : string ) {
290
+ this . logger . verbose ( "UrlContainsHash has been called" ) ;
290
291
return UrlUtils . urlContainsHash ( hash ) ;
291
292
}
292
293
293
294
private authResponseHandler ( interactionType : InteractionType , response : AuthResponse , resolve ?: any ) : void {
295
+ this . logger . verbose ( "AuthResponseHandler has been called" ) ;
296
+
294
297
if ( interactionType === Constants . interactionTypeRedirect ) {
298
+ this . logger . verbose ( "Interaction type is redirect" ) ;
295
299
if ( this . errorReceivedCallback ) {
300
+ this . logger . verbose ( "Two callbacks were provided to handleRedirectCallback, calling success callback with response" ) ;
296
301
this . tokenReceivedCallback ( response ) ;
297
302
} else if ( this . authResponseCallback ) {
303
+ this . logger . verbose ( "One callback was provided to handleRedirectCallback, calling authResponseCallback with response" ) ;
298
304
this . authResponseCallback ( null , response ) ;
299
305
}
300
306
} else if ( interactionType === Constants . interactionTypePopup ) {
307
+ this . logger . verbose ( "Interaction type is popup, resolving" ) ;
301
308
resolve ( response ) ;
302
309
} else {
303
310
throw ClientAuthError . createInvalidInteractionTypeError ( ) ;
304
311
}
305
312
}
306
313
307
314
private authErrorHandler ( interactionType : InteractionType , authErr : AuthError , response : AuthResponse , reject ?: any ) : void {
315
+ this . logger . verbose ( "AuthErrorHandler has been called" ) ;
316
+
308
317
// set interaction_status to complete
309
318
this . cacheStorage . removeItem ( TemporaryCacheKeys . INTERACTION_STATUS ) ;
310
319
if ( interactionType === Constants . interactionTypeRedirect ) {
320
+ this . logger . verbose ( "Interaction type is redirect" ) ;
311
321
if ( this . errorReceivedCallback ) {
322
+ this . logger . verbose ( "Two callbacks were provided to handleRedirectCallback, calling error callback" ) ;
312
323
this . errorReceivedCallback ( authErr , response . accountState ) ;
313
324
} else {
325
+ this . logger . verbose ( "One callback was provided to handleRedirectCallback, calling authResponseCallback with error" ) ;
314
326
this . authResponseCallback ( authErr , response ) ;
315
327
}
316
328
} else if ( interactionType === Constants . interactionTypePopup ) {
329
+ this . logger . verbose ( "Interaction type is popup, rejecting" ) ;
317
330
reject ( authErr ) ;
318
331
} else {
319
332
throw ClientAuthError . createInvalidInteractionTypeError ( ) ;
@@ -326,6 +339,8 @@ export class UserAgentApplication {
326
339
* @param {@link (AuthenticationParameters:type) }
327
340
*/
328
341
loginRedirect ( userRequest ?: AuthenticationParameters ) : void {
342
+ this . logger . verbose ( "LoginRedirect has been called" ) ;
343
+
329
344
// validate request
330
345
const request : AuthenticationParameters = RequestUtils . validateRequest ( userRequest , true , this . clientId , Constants . interactionTypeRedirect ) ;
331
346
this . acquireTokenInteractive ( Constants . interactionTypeRedirect , true , request , null , null ) ;
@@ -338,6 +353,8 @@ export class UserAgentApplication {
338
353
* To renew idToken, please pass clientId as the only scope in the Authentication Parameters
339
354
*/
340
355
acquireTokenRedirect ( userRequest : AuthenticationParameters ) : void {
356
+ this . logger . verbose ( "AcquireTokenRedirect has been called" ) ;
357
+
341
358
// validate request
342
359
const request : AuthenticationParameters = RequestUtils . validateRequest ( userRequest , false , this . clientId , Constants . interactionTypeRedirect ) ;
343
360
this . acquireTokenInteractive ( Constants . interactionTypeRedirect , false , request , null , null ) ;
@@ -351,6 +368,8 @@ export class UserAgentApplication {
351
368
* @returns {Promise.<AuthResponse> } - a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the {@link AuthResponse} object
352
369
*/
353
370
loginPopup ( userRequest ?: AuthenticationParameters ) : Promise < AuthResponse > {
371
+ this . logger . verbose ( "LoginPopup has been called" ) ;
372
+
354
373
// validate request
355
374
const request : AuthenticationParameters = RequestUtils . validateRequest ( userRequest , true , this . clientId , Constants . interactionTypePopup ) ;
356
375
const apiEvent : ApiEvent = this . telemetryManager . createAndStartApiEvent ( request . correlationId , API_EVENT_IDENTIFIER . LoginPopup ) ;
@@ -359,6 +378,7 @@ export class UserAgentApplication {
359
378
this . acquireTokenInteractive ( Constants . interactionTypePopup , true , request , resolve , reject ) ;
360
379
} )
361
380
. then ( ( resp ) => {
381
+ this . logger . verbose ( "Successfully logged in" ) ;
362
382
this . telemetryManager . stopAndFlushApiEvent ( request . correlationId , apiEvent , true ) ;
363
383
return resp ;
364
384
} )
@@ -651,6 +671,8 @@ export class UserAgentApplication {
651
671
* @param request
652
672
*/
653
673
ssoSilent ( request : AuthenticationParameters ) : Promise < AuthResponse > {
674
+ this . logger . verbose ( "ssoSilent has been called" ) ;
675
+
654
676
// throw an error on an empty request
655
677
if ( ! request ) {
656
678
throw ClientConfigurationError . createEmptyRequestError ( ) ;
@@ -1019,6 +1041,7 @@ export class UserAgentApplication {
1019
1041
* Default behaviour is to redirect the user to `window.location.href`.
1020
1042
*/
1021
1043
logout ( correlationId ?: string ) : void {
1044
+ this . logger . verbose ( "Logout has been called" ) ;
1022
1045
this . logoutAsync ( correlationId ) ;
1023
1046
}
1024
1047
@@ -1043,15 +1066,28 @@ export class UserAgentApplication {
1043
1066
1044
1067
const correlationIdParam = `client-request-id=${ requestCorrelationId } ` ;
1045
1068
1046
- const postLogoutQueryParam = this . getPostLogoutRedirectUri ( )
1047
- ? `&post_logout_redirect_uri=${ encodeURIComponent ( this . getPostLogoutRedirectUri ( ) ) } `
1048
- : "" ;
1069
+ let postLogoutQueryParam : string ;
1070
+ if ( this . getPostLogoutRedirectUri ( ) ) {
1071
+ postLogoutQueryParam = `&post_logout_redirect_uri=${ encodeURIComponent ( this . getPostLogoutRedirectUri ( ) ) } ` ;
1072
+ this . logger . verbose ( "redirectUri found and set" ) ;
1073
+ } else {
1074
+ postLogoutQueryParam = "" ;
1075
+ this . logger . verbose ( "No redirectUri set for app. postLogoutQueryParam is empty" ) ;
1076
+ }
1049
1077
1050
- const urlNavigate = this . authorityInstance . EndSessionEndpoint
1051
- ? `${ this . authorityInstance . EndSessionEndpoint } ?${ correlationIdParam } ${ postLogoutQueryParam } `
1052
- : `${ this . authority } oauth2/v2.0/logout?${ correlationIdParam } ${ postLogoutQueryParam } ` ;
1078
+ let urlNavigate : string ;
1079
+ if ( this . authorityInstance . EndSessionEndpoint ) {
1080
+ urlNavigate = `${ this . authorityInstance . EndSessionEndpoint } ?${ correlationIdParam } ${ postLogoutQueryParam } ` ;
1081
+ this . logger . verbose ( "EndSessionEndpoint found and urlNavigate set" ) ;
1082
+ this . logger . verbosePii ( `urlNavigate set to: ${ this . authorityInstance . EndSessionEndpoint } ` ) ;
1083
+ } else {
1084
+ urlNavigate = `${ this . authority } oauth2/v2.0/logout?${ correlationIdParam } ${ postLogoutQueryParam } ` ;
1085
+ this . logger . verbose ( "No endpoint, urlNavigate set to default" ) ;
1086
+ }
1053
1087
1054
1088
this . telemetryManager . stopAndFlushApiEvent ( requestCorrelationId , apiEvent , true ) ;
1089
+
1090
+ this . logger . verbose ( "Navigating window to urlNavigate" ) ;
1055
1091
this . navigateWindow ( urlNavigate ) ;
1056
1092
} catch ( error ) {
1057
1093
this . telemetryManager . stopAndFlushApiEvent ( requestCorrelationId , apiEvent , false , error . errorCode ) ;
@@ -1064,6 +1100,7 @@ export class UserAgentApplication {
1064
1100
* @ignore
1065
1101
*/
1066
1102
protected clearCache ( ) : void {
1103
+ this . logger . verbose ( "Clearing cache" ) ;
1067
1104
window . renewStates = [ ] ;
1068
1105
const accessTokenItems = this . cacheStorage . getAllAccessTokens ( Constants . clientId , Constants . homeAccountIdentifier ) ;
1069
1106
for ( let i = 0 ; i < accessTokenItems . length ; i ++ ) {
@@ -1072,6 +1109,7 @@ export class UserAgentApplication {
1072
1109
this . cacheStorage . resetCacheItems ( ) ;
1073
1110
// state not being sent would mean this call may not be needed; check later
1074
1111
this . cacheStorage . clearMsalCookie ( ) ;
1112
+ this . logger . verbose ( "Cache cleared" ) ;
1075
1113
}
1076
1114
1077
1115
/**
@@ -1081,11 +1119,13 @@ export class UserAgentApplication {
1081
1119
* @param accessToken
1082
1120
*/
1083
1121
protected clearCacheForScope ( accessToken : string ) {
1122
+ this . logger . verbose ( "Clearing access token from cache" ) ;
1084
1123
const accessTokenItems = this . cacheStorage . getAllAccessTokens ( Constants . clientId , Constants . homeAccountIdentifier ) ;
1085
1124
for ( let i = 0 ; i < accessTokenItems . length ; i ++ ) {
1086
1125
const token = accessTokenItems [ i ] ;
1087
1126
if ( token . value . accessToken === accessToken ) {
1088
1127
this . cacheStorage . removeItem ( JSON . stringify ( token . key ) ) ;
1128
+ this . logger . verbosePii ( `Access token removed: ${ token . key } ` ) ;
1089
1129
}
1090
1130
}
1091
1131
}
0 commit comments