Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions packages/core/src/auth/credentials/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import { messages, showMessageWithCancel, showViewLogsMessage } from '../../shar
import { Timeout, waitTimeout } from '../../shared/utilities/timeoutUtils'
import { fromExtensionManifest } from '../../shared/settings'
import { Profile } from './sharedCredentials'
import { createInputBox, promptUser } from '../../shared/ui/input'
import { openUrl } from '../../shared/utilities/vsCodeUtils'
import { createInputBox } from '../../shared/ui/inputPrompter'
import { isValidResponse } from '../../shared/wizards/wizard'

const credentialsTimeout = 300000 // 5 minutes
const credentialsProgressDelay = 1000
Expand Down Expand Up @@ -113,18 +114,16 @@ const errorMessageUserCancelled = localize('AWS.error.mfa.userCancelled', 'User
*/
export async function getMfaTokenFromUser(mfaSerial: string, profileName: string): Promise<string> {
const inputBox = createInputBox({
options: {
ignoreFocusOut: true,
placeHolder: localize('AWS.prompt.mfa.enterCode.placeholder', 'Enter Authentication Code Here'),
title: localize('AWS.prompt.mfa.enterCode.title', 'MFA Challenge for {0}', profileName),
prompt: localize('AWS.prompt.mfa.enterCode.prompt', 'Enter code for MFA device {0}', mfaSerial),
},
ignoreFocusOut: true,
placeholder: localize('AWS.prompt.mfa.enterCode.placeholder', 'Enter Authentication Code Here'),
title: localize('AWS.prompt.mfa.enterCode.title', 'MFA Challenge for {0}', profileName),
prompt: localize('AWS.prompt.mfa.enterCode.prompt', 'Enter code for MFA device {0}', mfaSerial),
})

const token = await promptUser({ inputBox: inputBox })
const token = await inputBox.prompt()

// Distinguish user cancel vs code entry issues with the error message
if (!token) {
if (!isValidResponse(token)) {
throw new Error(errorMessageUserCancelled)
}

Expand Down
Loading