Skip to content

Commit 20552b8

Browse files
committed
refactor: simplify conditional args
1 parent bf3af8f commit 20552b8

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

packages/core/src/auth/providers/sharedCredentialsProvider.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -413,17 +413,16 @@ export class SharedCredentialsProvider implements CredentialsProvider {
413413
secretAccessKey: sourceProfile.aws_secret_access_key!,
414414
})
415415
// Prompt for MFA Token if needed.
416-
const assumeRoleReq = profile.mfa_serial
417-
? {
418-
RoleArn: profile.role_arn,
419-
RoleSessionName: 'AssumeRoleSession',
420-
SerialNumber: profile.mfa_serial,
421-
TokenCode: await getMfaTokenFromUser(profile.mfa_serial, this.profileName),
422-
}
423-
: {
424-
RoleArn: profile.role_arn,
425-
RoleSessionName: 'AssumeRoleSession',
426-
}
416+
const assumeRoleReq = {
417+
RoleArn: profile.role_arn,
418+
RoleSessionName: 'AssumeRoleSession',
419+
...(profile.mfa_serial
420+
? {
421+
SerialNumber: profile.mfa_serial,
422+
TokenCode: await getMfaTokenFromUser(profile.mfa_serial, this.profileName),
423+
}
424+
: {}),
425+
}
427426
const assumeRoleRsp = await stsClient.assumeRole(assumeRoleReq)
428427
return {
429428
accessKeyId: assumeRoleRsp.Credentials!.AccessKeyId!,

0 commit comments

Comments
 (0)