Download node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js from sweet2004/bot: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/spaces/sweet2004/bot/resolve/main/node_modules/%40aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js
- Command line
-
hf download hf://spaces/sweet2004/bot/node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js
-
curl -L -o resolveProcessCredentials.js https://huggingface.co/spaces/sweet2004/bot/resolve/main/node_modules/%40aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js
1.38 kB
| import { CredentialsProviderError } from "@aws-sdk/property-provider"; | |
| import { exec } from "child_process"; | |
| import { promisify } from "util"; | |
| import { getValidatedProcessCredentials } from "./getValidatedProcessCredentials"; | |
| export const resolveProcessCredentials = async (profileName, profiles) => { | |
| const profile = profiles[profileName]; | |
| if (profiles[profileName]) { | |
| const credentialProcess = profile["credential_process"]; | |
| if (credentialProcess !== undefined) { | |
| const execPromise = promisify(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); | |
| } | |
| catch (error) { | |
| throw new CredentialsProviderError(error.message); | |
| } | |
| } | |
| else { | |
| throw new CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`); | |
| } | |
| } | |
| else { | |
| throw new CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`); | |
| } | |
| }; | |