@@ -160,25 +160,26 @@ export class AuthUtil implements IAuthProvider {
160160 }
161161 }
162162
163- // Log into the desired session type using the authentication parameters
164- async login ( accessKey : string , secretKey : string , loginType : 'iam' ) : Promise < GetIamCredentialResult | undefined >
165- async login ( startUrl : string , region : string , loginType : 'sso' ) : Promise < GetSsoTokenResult | undefined >
166- async login (
167- first : string ,
168- second : string ,
169- loginType : 'iam' | 'sso'
170- ) : Promise < GetSsoTokenResult | GetIamCredentialResult | undefined > {
171- let response : GetSsoTokenResult | GetIamCredentialResult | undefined
172-
173- // Start session if the current session type does not match the desired type
174- if ( loginType === 'sso' && ! this . isSsoSession ( ) ) {
163+ // Log in using SSO
164+ async login_sso ( startUrl : string , region : string ) : Promise < GetSsoTokenResult | undefined > {
165+ let response : GetSsoTokenResult | undefined
166+ // Create SSO login session
167+ if ( ! this . isSsoSession ( ) ) {
175168 this . session = new SsoLogin ( this . profileName , this . lspAuth , this . eventEmitter )
176- response = await this . session . login ( { startUrl : first , region : second , scopes : amazonQScopes } )
177- } else if ( loginType === 'iam' && ! this . isIamSession ( ) ) {
178- this . session = new IamLogin ( this . profileName , this . lspAuth , this . eventEmitter )
179- response = await this . session . login ( { accessKey : first , secretKey : second } )
180169 }
170+ response = await ( this . session as SsoLogin ) . login ( { startUrl : startUrl , region : region , scopes : amazonQScopes } )
171+ await showAmazonQWalkthroughOnce ( )
172+ return response
173+ }
181174
175+ // Log in using IAM or STS credentials
176+ async login_iam ( accessKey : string , secretKey : string , sessionToken ?: string ) : Promise < GetIamCredentialResult | undefined > {
177+ let response : GetIamCredentialResult | undefined
178+ // Create IAM login session
179+ if ( ! this . isIamSession ( ) ) {
180+ this . session = new IamLogin ( this . profileName , this . lspAuth , this . eventEmitter )
181+ }
182+ response = await ( this . session as IamLogin ) . login ( { accessKey : accessKey , secretKey : secretKey , sessionToken : sessionToken } )
182183 await showAmazonQWalkthroughOnce ( )
183184 return response
184185 }
0 commit comments