@@ -58,7 +58,7 @@ import { processUtils } from 'aws-core-vscode/shared'
5858import { activate as activateChat } from './chat/activation'
5959import { activate as activeInlineChat } from '../inlineChat/activation'
6060import { AmazonQResourcePaths } from './lspInstaller'
61- import { auth2 , getMfaTokenFromUser } from 'aws-core-vscode/auth'
61+ import { auth2 , getMfaTokenFromUser , getMfaSerialFromUser } from 'aws-core-vscode/auth'
6262import { ConfigSection , isValidConfigSection , pushConfigUpdate , toAmazonQLSPLogLevel } from './config'
6363import { telemetry } from 'aws-core-vscode/telemetry'
6464import { SessionManager } from '../app/inline/sessionManager'
@@ -343,8 +343,17 @@ async function postStartLanguageServer(
343343 client . onRequest (
344344 auth2 . notificationTypes . getMfaCode . method ,
345345 async ( params : GetMfaCodeParams ) : Promise < GetMfaCodeResult > => {
346- const mfaCode = await getMfaTokenFromUser ( params . mfaSerial , params . profileName )
347- return { code : mfaCode ?? '' }
346+ if ( params . mfaSerial ) {
347+ globals . globalState . update ( 'recentMfaSerial' , { mfaSerial : params . mfaSerial } )
348+ }
349+ const defaultMfaSerial = globals . globalState . tryGet ( 'recentMfaSerial' , Object , {
350+ mfaSerial : '' ,
351+ } ) . mfaSerial
352+ let mfaSerial = await getMfaSerialFromUser ( defaultMfaSerial , params . profileName )
353+ mfaSerial = mfaSerial . trim ( )
354+ globals . globalState . update ( 'recentMfaSerial' , { mfaSerial : mfaSerial } )
355+ const mfaCode = await getMfaTokenFromUser ( mfaSerial , params . profileName )
356+ return { code : mfaCode ?? '' , mfaSerial : mfaSerial ?? '' }
348357 }
349358 )
350359
0 commit comments