Skip to content

Commit b7a546d

Browse files
committed
fix merging disconnect
1 parent 324c47b commit b7a546d

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

packages/core/src/auth/auth2.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,13 @@ export abstract class BaseLogin {
373373
* Decrypts an encrypted string, removes its quotes, and returns the resulting string
374374
*/
375375
protected async decrypt(encrypted: string): Promise<string> {
376-
const decrypted = await jose.compactDecrypt(encrypted, this.lspAuth.encryptionKey)
377-
return decrypted.plaintext.toString().replaceAll('"', '')
376+
try {
377+
const decrypted = await jose.compactDecrypt(encrypted, this.lspAuth.encryptionKey)
378+
return decrypted.plaintext.toString().replaceAll('"', '')
379+
} catch (e) {
380+
getLogger().error(`Failed to decrypt: ${encrypted}`)
381+
return encrypted
382+
}
378383
}
379384
}
380385

@@ -586,6 +591,14 @@ export class IamLogin extends BaseLogin {
586591
* Restore the connection state and connection details to memory, if they exist.
587592
*/
588593
async restore() {
594+
const sessionData = await this.getProfile()
595+
const credentials = sessionData?.profile?.settings
596+
if (credentials?.aws_access_key_id && credentials?.aws_secret_access_key) {
597+
this._data = {
598+
accessKey: credentials.aws_access_key_id,
599+
secretKey: credentials.aws_secret_access_key,
600+
}
601+
}
589602
try {
590603
await this._getIamCredential(false)
591604
} catch (err) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export class AuthUtil implements IAuthProvider {
156156
await this.session.restore()
157157
if (!this.isConnected()) {
158158
// If both fail, reset the session
159-
await this.session?.logout()
159+
this.session = undefined
160160
}
161161
}
162162
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export abstract class CommonAuthWebview extends VueWebview {
187187
abstract fetchConnections(): Promise<AwsConnection[] | undefined>
188188

189189
async errorNotification(e: AuthError) {
190-
showMessage('error', e.text)
190+
await showMessage('error', e.text)
191191
}
192192

193193
abstract quitLoginScreen(): Promise<void>

0 commit comments

Comments
 (0)