File tree Expand file tree Collapse file tree 4 files changed +33
-9
lines changed Expand file tree Collapse file tree 4 files changed +33
-9
lines changed Original file line number Diff line number Diff line change @@ -376,8 +376,13 @@ export abstract class BaseLogin {
376376 * Decrypts an encrypted string, removes its quotes, and returns the resulting string
377377 */
378378 protected async decrypt(encrypted: string): Promise<string> {
379- const decrypted = await jose.compactDecrypt(encrypted, this.lspAuth.encryptionKey)
380- return decrypted.plaintext.toString().replaceAll('"', '')
379+ try {
380+ const decrypted = await jose.compactDecrypt(encrypted, this.lspAuth.encryptionKey)
381+ return decrypted.plaintext.toString().replaceAll('"', '')
382+ } catch (e) {
383+ getLogger().error(`Failed to decrypt: ${encrypted}`)
384+ return encrypted
385+ }
381386 }
382387}
383388
@@ -589,6 +594,14 @@ export class IamLogin extends BaseLogin {
589594 * Restore the connection state and connection details to memory, if they exist.
590595 */
591596 async restore() {
597+ const sessionData = await this.getProfile()
598+ const credentials = sessionData?.profile?.settings
599+ if (credentials?.aws_access_key_id && credentials?.aws_secret_access_key) {
600+ this._data = {
601+ accessKey: credentials.aws_access_key_id,
602+ secretKey: credentials.aws_secret_access_key,
603+ }
604+ }
592605 try {
593606 await this._getIamCredential(false)
594607 } catch (err) {
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ export class AuthUtil implements IAuthProvider {
155155 await this.session.restore()
156156 if (!this.isConnected()) {
157157 // If both fail, reset the session
158- await this.session?.logout()
158+ this.session = undefined
159159 }
160160 }
161161 }
Original file line number Diff line number Diff 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>
Original file line number Diff line number Diff line change @@ -26,16 +26,27 @@ export async function createTestAuthUtil() {
2626 },
2727 }
2828
29+ const fakeCredential = {
30+ credential: {
31+ id: 'fake-id',
32+ kinds: [],
33+ credentials: {
34+ accessKeyId: 'fake-access-key-id',
35+ secretAccessKey: 'fake-secret-access-key',
36+ sessionToken: 'fake-session-token',
37+ },
38+ },
39+ updateCredentialsParams: {
40+ data: 'fake-data',
41+ },
42+ }
43+
2944 const mockLspAuth: Partial<LanguageClientAuth> = {
3045 registerSsoTokenChangedHandler: sinon.stub().resolves(),
3146 registerStsCredentialChangedHandler: sinon.stub().resolves(),
3247 updateSsoProfile: sinon.stub().resolves(),
3348 getSsoToken: sinon.stub().resolves(fakeToken),
34- getIamCredential: sinon.stub().resolves({
35- accessKeyId: 'fake-access-key-id',
36- secretAccessKey: 'fake-secret-access-key',
37- sessionToken: 'fake-session-token',
38- }),
49+ getIamCredential: sinon.stub().resolves(fakeCredential),
3950 getProfile: sinon.stub().resolves({
4051 sso_registration_scopes: ['codewhisperer'],
4152 }),
You can’t perform that action at this time.
0 commit comments