Skip to content

Commit 5bfe0bf

Browse files
committed
fix eslint problems
1 parent 7fe8fcc commit 5bfe0bf

File tree

4 files changed

+40
-10
lines changed

4 files changed

+40
-10
lines changed

packages/amazonq/src/extensionNode.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ async function activateAmazonQNode(context: vscode.ExtensionContext) {
100100
async function getAuthState(): Promise<Omit<AuthUserState, 'source'>> {
101101
const state = AuthUtil.instance.getAuthState()
102102

103-
if (AuthUtil.instance.isConnected() && !(AuthUtil.instance.isSsoSession() || AuthUtil.instance.isIamSession() || isSageMaker())) {
103+
if (
104+
AuthUtil.instance.isConnected() &&
105+
!(AuthUtil.instance.isSsoSession() || AuthUtil.instance.isIamSession() || isSageMaker())
106+
) {
104107
getLogger().error('Current Amazon Q connection is not SSO nor IAM')
105108
}
106109

packages/core/src/codewhisperer/util/authUtil.ts

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ import { showAmazonQWalkthroughOnce } from '../../amazonq/onboardingPage/walkthr
3030
import { setContext } from '../../shared/vscode/setContext'
3131
import { openUrl } from '../../shared/utilities/vsCodeUtils'
3232
import { telemetry } from '../../shared/telemetry/telemetry'
33-
import { AuthStateEvent, cacheChangedEvent, stsCacheChangedEvent, LanguageClientAuth, Login, SsoLogin, IamLogin, LoginTypes } from '../../auth/auth2'
33+
import {
34+
AuthStateEvent,
35+
cacheChangedEvent,
36+
stsCacheChangedEvent,
37+
LanguageClientAuth,
38+
Login,
39+
SsoLogin,
40+
IamLogin,
41+
LoginTypes,
42+
} from '../../auth/auth2'
3443
import { builderIdStartUrl, internalStartUrl } from '../../auth/sso/constants'
3544
import { VSCODE_EXTENSION_ID } from '../../shared/extensions'
3645
import { RegionProfileManager } from '../region/regionProfileManager'
@@ -64,7 +73,14 @@ export interface IAuthProvider {
6473
getToken(): Promise<string>
6574
getIamCredential(): Promise<IamCredentials>
6675
readonly profileName: string
67-
readonly connection?: { startUrl?: string; region?: string; accessKey?: string; secretKey?: string; sessionToken?: string }
76+
readonly connection?: {
77+
startUrl?: string
78+
region?: string
79+
accessKey?: string
80+
secretKey?: string
81+
sessionToken?: string
82+
roleArn?: string
83+
}
6884
}
6985

7086
/**
@@ -175,13 +191,23 @@ export class AuthUtil implements IAuthProvider {
175191
}
176192

177193
// Log in using IAM or STS credentials
178-
async login_iam(accessKey: string, secretKey: string, sessionToken?: string, roleArn?: string): Promise<GetIamCredentialResult | undefined> {
194+
async login_iam(
195+
accessKey: string,
196+
secretKey: string,
197+
sessionToken?: string,
198+
roleArn?: string
199+
): Promise<GetIamCredentialResult | undefined> {
179200
let response: GetIamCredentialResult | undefined
180201
// Create IAM login session
181202
if (!this.isIamSession()) {
182203
this.session = new IamLogin(this.profileName, this.lspAuth, this.eventEmitter)
183204
}
184-
response = await (this.session as IamLogin).login({ accessKey: accessKey, secretKey: secretKey, sessionToken: sessionToken, roleArn: roleArn })
205+
response = await (this.session as IamLogin).login({
206+
accessKey: accessKey,
207+
secretKey: secretKey,
208+
sessionToken: sessionToken,
209+
roleArn: roleArn,
210+
})
185211
await showAmazonQWalkthroughOnce()
186212
return response
187213
}
@@ -375,10 +401,9 @@ export class AuthUtil implements IAuthProvider {
375401

376402
private async refreshState(state = this.getAuthState()) {
377403
if (state === 'expired' || state === 'notConnected') {
378-
if (this.isSsoSession()){
404+
if (this.isSsoSession()) {
379405
this.lspAuth.deleteBearerToken()
380-
}
381-
else if (this.isIamSession()){
406+
} else if (this.isIamSession()) {
382407
this.lspAuth.deleteIamCredential()
383408
}
384409
if (this.isIdcConnection()) {
@@ -440,6 +465,8 @@ export class AuthUtil implements IAuthProvider {
440465
} else if (this.isIamSession()) {
441466
return {
442467
credentialSourceId: 'sharedCredentials',
468+
credentialAccessKey: AuthUtil.instance.connection?.accessKey,
469+
credentialRoleArn: AuthUtil.instance.connection?.roleArn,
443470
}
444471
}
445472

packages/core/src/login/webview/vue/amazonq/backend_amazonq.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export class AmazonQLoginWebview extends CommonAuthWebview {
209209
await AuthUtil.instance.login_iam(accessKey, secretKey, sessionToken, roleArn)
210210
} catch (e) {
211211
getLogger().error('Failed submitting credentials %O', e)
212-
const message = e instanceof Error ? e.message : e as string
212+
const message = e instanceof Error ? e.message : (e as string)
213213
return { id: this.id, text: message }
214214
}
215215
// Enable code suggestions

packages/core/src/login/webview/vue/backend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export abstract class CommonAuthWebview extends VueWebview {
177177
accessKey: string,
178178
secretKey: string,
179179
sessionToken?: string,
180-
role_arn?: string
180+
roleArn?: string
181181
): Promise<AuthError | undefined>
182182

183183
async showResourceExplorer(): Promise<void> {

0 commit comments

Comments
 (0)