@@ -188,7 +188,7 @@ export class Auth implements AuthService, ConnectionManager {
188
188
if ( profile === undefined ) {
189
189
throw new Error ( `Connection does not exist: ${ id } ` )
190
190
}
191
-
191
+ getLogger ( ) . info ( `auth: validating connection before using it: ${ id } ` )
192
192
const validated = await this . validateConnection ( id , profile )
193
193
const conn =
194
194
validated . type === 'sso' ? this . getSsoConnection ( id , validated ) : this . getIamConnection ( id , validated )
@@ -204,7 +204,7 @@ export class Auth implements AuthService, ConnectionManager {
204
204
if ( this . activeConnection === undefined ) {
205
205
return
206
206
}
207
-
207
+ getLogger ( ) . info ( `auth: logout` )
208
208
await this . store . setCurrentProfileId ( undefined )
209
209
await this . invalidateConnection ( this . activeConnection . id )
210
210
this . #activeConnection = undefined
@@ -339,6 +339,7 @@ export class Auth implements AuthService, ConnectionManager {
339
339
* Put the SSO connection in to an expired state
340
340
*/
341
341
public async expireConnection ( conn : Pick < SsoConnection , 'id' > ) : Promise < void > {
342
+ getLogger ( ) . info ( `auth: Expiring connection ${ conn . id } ` )
342
343
const profile = this . store . getProfileOrThrow ( conn . id )
343
344
if ( profile . type === 'iam' ) {
344
345
throw new ToolkitError ( 'Auth: Cannot force expire an IAM connection' )
@@ -374,6 +375,7 @@ export class Auth implements AuthService, ConnectionManager {
374
375
375
376
public async updateConnection ( connection : Pick < SsoConnection , 'id' > , profile : SsoProfile ) : Promise < SsoConnection >
376
377
public async updateConnection ( connection : Pick < Connection , 'id' > , profile : Profile ) : Promise < Connection > {
378
+ getLogger ( ) . info ( `auth: Updating connection ${ connection . id } ` )
377
379
if ( profile . type === 'iam' ) {
378
380
throw new Error ( 'Updating IAM connections is not supported' )
379
381
}
@@ -454,6 +456,7 @@ export class Auth implements AuthService, ConnectionManager {
454
456
* before the local token(s) are cleared as they are needed in the request.
455
457
*/
456
458
private async invalidateConnection ( id : Connection [ 'id' ] , opt ?: { skipGlobalLogout ?: boolean } ) {
459
+ getLogger ( ) . info ( `auth: Invalidating connection: ${ id } ` )
457
460
const profile = this . store . getProfileOrThrow ( id )
458
461
459
462
if ( profile . type === 'sso' ) {
@@ -479,6 +482,7 @@ export class Auth implements AuthService, ConnectionManager {
479
482
}
480
483
481
484
private async updateConnectionState ( id : Connection [ 'id' ] , connectionState : ProfileMetadata [ 'connectionState' ] ) {
485
+ getLogger ( ) . info ( `auth: Updating connection state of ${ id } to ${ connectionState } ` )
482
486
const oldProfile = this . store . getProfileOrThrow ( id )
483
487
if ( oldProfile . metadata . connectionState === connectionState ) {
484
488
return oldProfile
@@ -504,8 +508,10 @@ export class Auth implements AuthService, ConnectionManager {
504
508
if ( profile . type === 'sso' ) {
505
509
const provider = this . getTokenProvider ( id , profile )
506
510
if ( ( await provider . getToken ( ) ) === undefined ) {
511
+ getLogger ( ) . info ( `auth: Connection is not valid: ${ id } ` )
507
512
return this . updateConnectionState ( id , 'invalid' )
508
513
} else {
514
+ getLogger ( ) . info ( `auth: Connection is valid: ${ id } ` )
509
515
return this . updateConnectionState ( id , 'valid' )
510
516
}
511
517
} else {
@@ -539,7 +545,7 @@ export class Auth implements AuthService, ConnectionManager {
539
545
540
546
private async handleValidationError ( id : Connection [ 'id' ] , err : unknown ) {
541
547
this . #validationErrors. set ( id , UnknownError . cast ( err ) )
542
-
548
+ getLogger ( ) . info ( `auth: Handling validation error of connection: ${ id } ` )
543
549
return this . updateConnectionState ( id , 'invalid' )
544
550
}
545
551
@@ -736,6 +742,7 @@ export class Auth implements AuthService, ConnectionManager {
736
742
}
737
743
738
744
private async handleInvalidCredentials < T > ( id : Connection [ 'id' ] , refresh : ( ) => Promise < T > ) : Promise < T > {
745
+ getLogger ( ) . info ( `auth: Handling invalid credentials of connection: ${ id } ` )
739
746
const profile = this . store . getProfile ( id )
740
747
const previousState = profile ?. metadata . connectionState
741
748
await this . updateConnectionState ( id , 'invalid' )
0 commit comments