remove node_modules and .gitignore them
This commit is contained in:
-6
@@ -1,6 +0,0 @@
|
||||
import { getProfileName, parseKnownFiles } from "@smithy/shared-ini-file-loader";
|
||||
import { resolveProfileData } from "./resolveProfileData";
|
||||
export const fromIni = (init = {}) => async () => {
|
||||
const profiles = await parseKnownFiles(init);
|
||||
return resolveProfileData(getProfileName(init), profiles, init);
|
||||
};
|
||||
-1
@@ -1 +0,0 @@
|
||||
export * from "./fromIni";
|
||||
Generated
Vendored
-47
@@ -1,47 +0,0 @@
|
||||
import { CredentialsProviderError } from "@smithy/property-provider";
|
||||
import { getProfileName } from "@smithy/shared-ini-file-loader";
|
||||
import { resolveCredentialSource } from "./resolveCredentialSource";
|
||||
import { resolveProfileData } from "./resolveProfileData";
|
||||
export const isAssumeRoleProfile = (arg) => Boolean(arg) &&
|
||||
typeof arg === "object" &&
|
||||
typeof arg.role_arn === "string" &&
|
||||
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 &&
|
||||
["undefined", "string"].indexOf(typeof arg.external_id) > -1 &&
|
||||
["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1 &&
|
||||
(isAssumeRoleWithSourceProfile(arg) || isAssumeRoleWithProviderProfile(arg));
|
||||
const isAssumeRoleWithSourceProfile = (arg) => typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
|
||||
const isAssumeRoleWithProviderProfile = (arg) => typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
|
||||
export const resolveAssumeRoleCredentials = async (profileName, profiles, options, visitedProfiles = {}) => {
|
||||
const data = profiles[profileName];
|
||||
if (!options.roleAssumer) {
|
||||
throw new CredentialsProviderError(`Profile ${profileName} requires a role to be assumed, but no role assumption callback was provided.`, false);
|
||||
}
|
||||
const { source_profile } = data;
|
||||
if (source_profile && source_profile in visitedProfiles) {
|
||||
throw new CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile` +
|
||||
` ${getProfileName(options)}. Profiles visited: ` +
|
||||
Object.keys(visitedProfiles).join(", "), false);
|
||||
}
|
||||
const sourceCredsProvider = source_profile
|
||||
? resolveProfileData(source_profile, profiles, options, {
|
||||
...visitedProfiles,
|
||||
[source_profile]: true,
|
||||
})
|
||||
: resolveCredentialSource(data.credential_source, profileName)();
|
||||
const params = {
|
||||
RoleArn: data.role_arn,
|
||||
RoleSessionName: data.role_session_name || `aws-sdk-js-${Date.now()}`,
|
||||
ExternalId: data.external_id,
|
||||
DurationSeconds: parseInt(data.duration_seconds || "3600", 10),
|
||||
};
|
||||
const { mfa_serial } = data;
|
||||
if (mfa_serial) {
|
||||
if (!options.mfaCodeProvider) {
|
||||
throw new CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication, but no MFA code callback was provided.`, false);
|
||||
}
|
||||
params.SerialNumber = mfa_serial;
|
||||
params.TokenCode = await options.mfaCodeProvider(mfa_serial);
|
||||
}
|
||||
const sourceCreds = await sourceCredsProvider;
|
||||
return options.roleAssumer(sourceCreds, params);
|
||||
};
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
import { fromEnv } from "@aws-sdk/credential-provider-env";
|
||||
import { fromContainerMetadata, fromInstanceMetadata } from "@smithy/credential-provider-imds";
|
||||
import { CredentialsProviderError } from "@smithy/property-provider";
|
||||
export const resolveCredentialSource = (credentialSource, profileName) => {
|
||||
const sourceProvidersMap = {
|
||||
EcsContainer: fromContainerMetadata,
|
||||
Ec2InstanceMetadata: fromInstanceMetadata,
|
||||
Environment: fromEnv,
|
||||
};
|
||||
if (credentialSource in sourceProvidersMap) {
|
||||
return sourceProvidersMap[credentialSource]();
|
||||
}
|
||||
else {
|
||||
throw new CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, ` +
|
||||
`expected EcsContainer or Ec2InstanceMetadata or Environment.`);
|
||||
}
|
||||
};
|
||||
Generated
Vendored
-6
@@ -1,6 +0,0 @@
|
||||
import { fromProcess } from "@aws-sdk/credential-provider-process";
|
||||
export const isProcessProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.credential_process === "string";
|
||||
export const resolveProcessCredentials = async (options, profile) => fromProcess({
|
||||
...options,
|
||||
profile,
|
||||
})();
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
import { CredentialsProviderError } from "@smithy/property-provider";
|
||||
import { isAssumeRoleProfile, resolveAssumeRoleCredentials } from "./resolveAssumeRoleCredentials";
|
||||
import { isProcessProfile, resolveProcessCredentials } from "./resolveProcessCredentials";
|
||||
import { isSsoProfile, resolveSsoCredentials } from "./resolveSsoCredentials";
|
||||
import { isStaticCredsProfile, resolveStaticCredentials } from "./resolveStaticCredentials";
|
||||
import { isWebIdentityProfile, resolveWebIdentityCredentials } from "./resolveWebIdentityCredentials";
|
||||
export const resolveProfileData = async (profileName, profiles, options, visitedProfiles = {}) => {
|
||||
const data = profiles[profileName];
|
||||
if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) {
|
||||
return resolveStaticCredentials(data);
|
||||
}
|
||||
if (isAssumeRoleProfile(data)) {
|
||||
return resolveAssumeRoleCredentials(profileName, profiles, options, visitedProfiles);
|
||||
}
|
||||
if (isStaticCredsProfile(data)) {
|
||||
return resolveStaticCredentials(data);
|
||||
}
|
||||
if (isWebIdentityProfile(data)) {
|
||||
return resolveWebIdentityCredentials(data, options);
|
||||
}
|
||||
if (isProcessProfile(data)) {
|
||||
return resolveProcessCredentials(options, profileName);
|
||||
}
|
||||
if (isSsoProfile(data)) {
|
||||
return resolveSsoCredentials(data);
|
||||
}
|
||||
throw new CredentialsProviderError(`Profile ${profileName} could not be found or parsed in shared credentials file.`);
|
||||
};
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
import { fromSSO, validateSsoProfile } from "@aws-sdk/credential-provider-sso";
|
||||
export { isSsoProfile } from "@aws-sdk/credential-provider-sso";
|
||||
export const resolveSsoCredentials = (data) => {
|
||||
const { sso_start_url, sso_account_id, sso_session, sso_region, sso_role_name } = validateSsoProfile(data);
|
||||
return fromSSO({
|
||||
ssoStartUrl: sso_start_url,
|
||||
ssoAccountId: sso_account_id,
|
||||
ssoSession: sso_session,
|
||||
ssoRegion: sso_region,
|
||||
ssoRoleName: sso_role_name,
|
||||
})();
|
||||
};
|
||||
Generated
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
export const isStaticCredsProfile = (arg) => Boolean(arg) &&
|
||||
typeof arg === "object" &&
|
||||
typeof arg.aws_access_key_id === "string" &&
|
||||
typeof arg.aws_secret_access_key === "string" &&
|
||||
["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1;
|
||||
export const resolveStaticCredentials = (profile) => Promise.resolve({
|
||||
accessKeyId: profile.aws_access_key_id,
|
||||
secretAccessKey: profile.aws_secret_access_key,
|
||||
sessionToken: profile.aws_session_token,
|
||||
});
|
||||
Generated
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
import { fromTokenFile } from "@aws-sdk/credential-provider-web-identity";
|
||||
export const isWebIdentityProfile = (arg) => Boolean(arg) &&
|
||||
typeof arg === "object" &&
|
||||
typeof arg.web_identity_token_file === "string" &&
|
||||
typeof arg.role_arn === "string" &&
|
||||
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1;
|
||||
export const resolveWebIdentityCredentials = async (profile, options) => fromTokenFile({
|
||||
webIdentityTokenFile: profile.web_identity_token_file,
|
||||
roleArn: profile.role_arn,
|
||||
roleSessionName: profile.role_session_name,
|
||||
roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
|
||||
})();
|
||||
Reference in New Issue
Block a user