@@ -51,7 +51,6 @@ import {
5151 SsoSession ,
5252 GetMfaCodeParams ,
5353 getMfaCodeRequestType ,
54-
5554} from '@aws/language-server-runtimes/protocol'
5655import { LanguageClient } from 'vscode-languageclient'
5756import { getLogger } from '../shared/logger/logger'
@@ -73,9 +72,7 @@ export const notificationTypes = {
7372 getConnectionMetadata : new RequestType < undefined , ConnectionMetadata , Error > (
7473 getConnectionMetadataRequestType . method
7574 ) ,
76- getMfaCode : new RequestType < GetMfaCodeParams , ResponseMessage , Error > (
77- getMfaCodeRequestType . method
78- )
75+ getMfaCode : new RequestType < GetMfaCodeParams , ResponseMessage , Error > ( getMfaCodeRequestType . method ) ,
7976}
8077
8178export type AuthState = 'notConnected' | 'connected' | 'expired'
@@ -101,7 +98,10 @@ export type TokenSource = IamIdentityCenterSsoTokenSource | AwsBuilderIdSsoToken
10198 */
10299export class LanguageClientAuth {
103100 readonly #ssoCacheWatcher = getCacheFileWatcher ( getCacheDir ( ) , getFlareCacheFileName ( VSCODE_EXTENSION_ID . amazonq ) )
104- readonly #stsCacheWatcher = getCacheFileWatcher ( getStsCacheDir ( ) , getFlareCacheFileName ( VSCODE_EXTENSION_ID . amazonq ) )
101+ readonly #stsCacheWatcher = getCacheFileWatcher (
102+ getStsCacheDir ( ) ,
103+ getFlareCacheFileName ( VSCODE_EXTENSION_ID . amazonq )
104+ )
105105
106106 constructor (
107107 private readonly client : LanguageClient ,
@@ -279,7 +279,7 @@ export class LanguageClientAuth {
279279
280280 invalidateStsCredential ( tokenId : string ) {
281281 return this . client . sendRequest ( invalidateStsCredentialRequestType . method , {
282- profileName : tokenId ,
282+ iamCredentialId : tokenId ,
283283 } satisfies InvalidateStsCredentialParams ) as Promise < InvalidateStsCredentialResult >
284284 }
285285
@@ -309,7 +309,9 @@ export abstract class BaseLogin {
309309 protected loginType : LoginType | undefined
310310 protected connectionState : AuthState = 'notConnected'
311311 protected cancellationToken : CancellationTokenSource | undefined
312- protected _data : { startUrl ?: string ; region ?: string ; accessKey ?: string ; secretKey ?: string ; sessionToken ?: string } | undefined
312+ protected _data :
313+ | { startUrl ?: string ; region ?: string ; accessKey ?: string ; secretKey ?: string ; sessionToken ?: string }
314+ | undefined
313315
314316 constructor (
315317 public readonly profileName : string ,
@@ -536,7 +538,7 @@ export class IamLogin extends BaseLogin {
536538 )
537539 }
538540
539- async login ( opts : { accessKey : string ; secretKey : string , sessionToken ?: string , roleArn ?: string } ) {
541+ async login ( opts : { accessKey : string ; secretKey : string ; sessionToken ?: string ; roleArn ?: string } ) {
540542 await this . updateProfile ( opts )
541543 return this . _getIamCredential ( true )
542544 }
@@ -559,13 +561,27 @@ export class IamLogin extends BaseLogin {
559561 // TODO: DeleteProfile api in Identity Service (this doesn't exist yet)
560562 }
561563
562- async updateProfile ( opts : { accessKey : string ; secretKey : string , sessionToken ?: string , roleArn ?: string } ) {
564+ async updateProfile ( opts : { accessKey : string ; secretKey : string ; sessionToken ?: string ; roleArn ?: string } ) {
563565 if ( opts . roleArn ) {
564566 const sourceProfile = this . profileName + '-source'
565- await this . lspAuth . updateIamProfile ( sourceProfile , opts . accessKey , opts . secretKey , opts . sessionToken , '' , '' )
567+ await this . lspAuth . updateIamProfile (
568+ sourceProfile ,
569+ opts . accessKey ,
570+ opts . secretKey ,
571+ opts . sessionToken ,
572+ '' ,
573+ ''
574+ )
566575 await this . lspAuth . updateIamProfile ( this . profileName , '' , '' , '' , opts . roleArn , sourceProfile )
567576 } else {
568- await this . lspAuth . updateIamProfile ( this . profileName , opts . accessKey , opts . secretKey , opts . sessionToken , '' , '' )
577+ await this . lspAuth . updateIamProfile (
578+ this . profileName ,
579+ opts . accessKey ,
580+ opts . secretKey ,
581+ opts . sessionToken ,
582+ '' ,
583+ ''
584+ )
569585 }
570586 }
571587
@@ -587,10 +603,10 @@ export class IamLogin extends BaseLogin {
587603 async getCredential ( ) {
588604 const response = await this . _getIamCredential ( false )
589605 const credentials : IamCredentials = {
590- accessKeyId : await this . decrypt ( response . credentials . accessKeyId ) ,
591- secretAccessKey : await this . decrypt ( response . credentials . secretAccessKey ) ,
592- sessionToken : response . credentials . sessionToken
593- ? await this . decrypt ( response . credentials . sessionToken )
606+ accessKeyId : await this . decrypt ( response . credential . credentials . accessKeyId ) ,
607+ secretAccessKey : await this . decrypt ( response . credential . credentials . secretAccessKey ) ,
608+ sessionToken : response . credential . credentials . sessionToken
609+ ? await this . decrypt ( response . credential . credentials . sessionToken )
594610 : undefined ,
595611 }
596612 return {
@@ -629,13 +645,13 @@ export class IamLogin extends BaseLogin {
629645 }
630646
631647 // Update cached credentials and credential ID
632- if ( response . credentials . accessKeyId && response . credentials . secretAccessKey ) {
648+ if ( response . credential . credentials . accessKeyId && response . credential . credentials . secretAccessKey ) {
633649 this . _data = {
634- accessKey : response . credentials . accessKeyId ,
635- secretKey : response . credentials . secretAccessKey ,
636- sessionToken : response . credentials . sessionToken ,
650+ accessKey : response . credential . credentials . accessKeyId ,
651+ secretKey : response . credential . credentials . secretAccessKey ,
652+ sessionToken : response . credential . credentials . sessionToken ,
637653 }
638- this . iamCredentialId = response . id
654+ this . iamCredentialId = response . credential . id
639655 }
640656 this . updateConnectionState ( 'connected' )
641657 return response
@@ -647,7 +663,7 @@ export class IamLogin extends BaseLogin {
647663 this . updateConnectionState ( 'expired' )
648664 return
649665 } else if ( params . kind === StsCredentialChangedKind . Refreshed ) {
650- this . eventEmitter . fire ( { id : this . profileName , state : 'refreshed' } )
666+ this . eventEmitter . fire ( { id : this . iamCredentialId , state : 'refreshed' } )
651667 }
652668 }
653669 }
0 commit comments