@@ -22,9 +22,10 @@ import {
2222 UpdateProfileParams ,
2323 updateProfileRequestType ,
2424 SsoTokenChangedParams ,
25- // StsCredentialChangedParams,
25+ StsCredentialChangedParams ,
26+ StsCredentialChangedKind ,
2627 ssoTokenChangedRequestType ,
27- // stsCredentialChangedRequestType,
28+ stsCredentialChangedRequestType ,
2829 AwsBuilderIdSsoTokenSource ,
2930 UpdateCredentialsParams ,
3031 AwsErrorCodes ,
@@ -233,12 +234,6 @@ export class LanguageClientAuth {
233234 } satisfies InvalidateSsoTokenParams ) as Promise < InvalidateSsoTokenResult >
234235 }
235236
236- // invalidateStsCredential(tokenId: string) {
237- // return this.client.sendRequest(invalidateStsCredentialRequestType.method, {
238- // iamCredentialsId: tokenId,
239- // } satisfies InvalidateStsCredentialParams) as Promise<InvalidateStsCredentialResult>
240- // }
241-
242237 invalidateStsCredential ( tokenId : string ) {
243238 return this . client . sendRequest ( invalidateStsCredentialRequestType . method , {
244239 profileName : tokenId ,
@@ -249,9 +244,9 @@ export class LanguageClientAuth {
249244 this . client . onNotification ( ssoTokenChangedRequestType . method , ssoTokenChangedHandler )
250245 }
251246
252- // registerStsCredentialChangedHandler(stsCredentialChangedHandler: (params: StsCredentialChangedParams) => any) {
253- // this.client.onNotification(stsCredentialChangedRequestType.method, stsCredentialChangedHandler)
254- // }
247+ registerStsCredentialChangedHandler ( stsCredentialChangedHandler : ( params : StsCredentialChangedParams ) => any ) {
248+ this . client . onNotification ( stsCredentialChangedRequestType . method , stsCredentialChangedHandler )
249+ }
255250
256251 registerCacheWatcher ( cacheChangedHandler : ( event : cacheChangedEvent ) => any ) {
257252 this . cacheWatcher . onDidCreate ( ( ) => cacheChangedHandler ( 'create' ) )
@@ -485,9 +480,9 @@ export class IamLogin extends BaseLogin {
485480
486481 constructor ( profileName : string , lspAuth : LanguageClientAuth , eventEmitter : vscode . EventEmitter < AuthStateEvent > ) {
487482 super ( profileName , lspAuth , eventEmitter )
488- // lspAuth.registerStsCredentialChangedHandler((params: StsCredentialChangedParams) =>
489- // this.stsCredentialChangedHandler(params)
490- // )
483+ lspAuth . registerStsCredentialChangedHandler ( ( params : StsCredentialChangedParams ) =>
484+ this . stsCredentialChangedHandler ( params )
485+ )
491486 }
492487
493488 async login ( opts : { accessKey : string ; secretKey : string , sessionToken ?: string , roleArn ?: string } ) {
@@ -594,14 +589,14 @@ export class IamLogin extends BaseLogin {
594589 return response
595590 }
596591
597- // private stsCredentialChangedHandler(params: StsCredentialChangedParams) {
598- // if (params.stsCredentialId === this.iamCredentialId) {
599- // if (params.kind === StsCredentialChangedKind.Expired) {
600- // this.updateConnectionState('expired')
601- // return
602- // } else if (params.kind === StsCredentialChangedKind.Refreshed) {
603- // this.eventEmitter.fire({ id: this.profileName, state: 'refreshed' })
604- // }
605- // }
606- // }
592+ private stsCredentialChangedHandler ( params : StsCredentialChangedParams ) {
593+ if ( params . stsCredentialId === this . iamCredentialId ) {
594+ if ( params . kind === StsCredentialChangedKind . Expired ) {
595+ this . updateConnectionState ( 'expired' )
596+ return
597+ } else if ( params . kind === StsCredentialChangedKind . Refreshed ) {
598+ this . eventEmitter . fire ( { id : this . profileName , state : 'refreshed' } )
599+ }
600+ }
601+ }
607602}
0 commit comments