初始化环境文件
This commit is contained in:
36
node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js
generated
vendored
Normal file
36
node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import { CredentialsProviderError } from "@smithy/property-provider";
|
||||
import { externalDataInterceptor } from "@smithy/shared-ini-file-loader";
|
||||
import { exec } from "node:child_process";
|
||||
import { promisify } from "node:util";
|
||||
import { getValidatedProcessCredentials } from "./getValidatedProcessCredentials";
|
||||
export const resolveProcessCredentials = async (profileName, profiles, logger) => {
|
||||
const profile = profiles[profileName];
|
||||
if (profiles[profileName]) {
|
||||
const credentialProcess = profile["credential_process"];
|
||||
if (credentialProcess !== undefined) {
|
||||
const execPromise = promisify(externalDataInterceptor?.getTokenRecord?.().exec ?? exec);
|
||||
try {
|
||||
const { stdout } = await execPromise(credentialProcess);
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(stdout.trim());
|
||||
}
|
||||
catch {
|
||||
throw Error(`Profile ${profileName} credential_process returned invalid JSON.`);
|
||||
}
|
||||
return getValidatedProcessCredentials(profileName, data, profiles);
|
||||
}
|
||||
catch (error) {
|
||||
throw new CredentialsProviderError(error.message, { logger });
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`, { logger });
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`, {
|
||||
logger,
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user