Skip to content

Commit 956fd89

Browse files
fix(credential-provider): address feedbacks
Co-authored-by: Trivikram Kamat <[email protected]>
1 parent 6ebe687 commit 956fd89

File tree

2 files changed

+13
-11
lines changed
  • packages

2 files changed

+13
-11
lines changed

packages/credential-provider-ini/src/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ const isAssumeRoleProfile = (arg: any): arg is AssumeRoleProfile =>
111111
* Creates a credential provider that will read from ini files and supports
112112
* role assumption and multi-factor authentication.
113113
*/
114-
export const fromIni = (init: FromIniInit = {}): CredentialProvider => () =>
115-
parseKnownFiles(init).then((profiles) => resolveProfileData(getMasterProfileName(init), profiles, init));
114+
export const fromIni = (init: FromIniInit = {}): CredentialProvider => async () => {
115+
const profiles = await parseKnownFiles(init);
116+
return resolveProfileData(getMasterProfileName(init), profiles, init);
117+
};
116118

117119
/**
118120
* Load profiles from credentials and config INI files and normalize them into a
@@ -123,13 +125,11 @@ export const fromIni = (init: FromIniInit = {}): CredentialProvider => () =>
123125
export const parseKnownFiles = async (init: SourceProfileInit): Promise<ParsedIniData> => {
124126
const { loadedConfig = loadSharedConfigFiles(init) } = init;
125127

126-
return loadedConfig.then((parsedFiles) => {
127-
const { configFile, credentialsFile } = parsedFiles;
128-
return {
129-
...configFile,
130-
...credentialsFile,
131-
};
132-
});
128+
const parsedFiles = await loadedConfig;
129+
return {
130+
...parsedFiles.configFile,
131+
...parsedFiles.credentialsFile,
132+
};
133133
};
134134

135135
/**

packages/credential-provider-process/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ export interface FromProcessInit extends SourceProfileInit {}
1515
* Creates a credential provider that will read from a credential_process specified
1616
* in ini files.
1717
*/
18-
export const fromProcess = (init: FromProcessInit = {}): CredentialProvider => () =>
19-
parseKnownFiles(init).then((profiles) => resolveProcessCredentials(getMasterProfileName(init), profiles));
18+
export const fromProcess = (init: FromProcessInit = {}): CredentialProvider => async () => {
19+
const profiles = await parseKnownFiles(init);
20+
return resolveProcessCredentials(getMasterProfileName(init), profiles);
21+
};
2022

2123
async function resolveProcessCredentials(profileName: string, profiles: ParsedIniData): Promise<Credentials> {
2224
const profile = profiles[profileName];

0 commit comments

Comments
 (0)