@aws-sdk/credential-provider-ini 3.47.2 → 3.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/dist-cjs/fromIni.js +10 -0
- package/dist-cjs/index.js +2 -103
- package/dist-cjs/resolveAssumeRoleCredentials.js +51 -0
- package/dist-cjs/resolveCredentialSource.js +21 -0
- package/dist-cjs/resolveProfileData.js +28 -0
- package/dist-cjs/resolveSsoCredentials.js +16 -0
- package/dist-cjs/resolveStaticCredentials.js +15 -0
- package/dist-cjs/resolveWebIdentityCredentials.js +17 -0
- package/dist-es/fromIni.js +17 -0
- package/dist-es/index.js +1 -141
- package/dist-es/resolveAssumeRoleCredentials.js +65 -0
- package/dist-es/resolveCredentialSource.js +17 -0
- package/dist-es/resolveProfileData.js +31 -0
- package/dist-es/resolveSsoCredentials.js +11 -0
- package/dist-es/resolveStaticCredentials.js +14 -0
- package/dist-es/resolveWebIdentityCredentials.js +19 -0
- package/dist-types/fromIni.d.ts +36 -0
- package/dist-types/index.d.ts +1 -63
- package/dist-types/resolveAssumeRoleCredentials.d.ts +34 -0
- package/dist-types/resolveCredentialSource.d.ts +9 -0
- package/dist-types/resolveProfileData.d.ts +6 -0
- package/dist-types/resolveSsoCredentials.d.ts +3 -0
- package/dist-types/resolveStaticCredentials.d.ts +9 -0
- package/dist-types/resolveWebIdentityCredentials.d.ts +10 -0
- package/dist-types/ts3.4/fromIni.d.ts +14 -0
- package/dist-types/ts3.4/index.d.ts +1 -26
- package/dist-types/ts3.4/resolveAssumeRoleCredentials.d.ts +19 -0
- package/dist-types/ts3.4/resolveCredentialSource.d.ts +3 -0
- package/dist-types/ts3.4/resolveProfileData.d.ts +6 -0
- package/dist-types/ts3.4/resolveSsoCredentials.d.ts +3 -0
- package/dist-types/ts3.4/resolveStaticCredentials.d.ts +9 -0
- package/dist-types/ts3.4/resolveWebIdentityCredentials.d.ts +10 -0
- package/package.json +16 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,41 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.51.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.50.0...v3.51.0) (2022-02-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **credential-provider-ini:** refactor into modular components ([#3289](https://github.com/aws/aws-sdk-js-v3/issues/3289)) ([7c891b2](https://github.com/aws/aws-sdk-js-v3/commit/7c891b215cf3a9ea343447ced51e5d7be86caba9))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [3.50.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.49.0...v3.50.0) (2022-02-08)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @aws-sdk/credential-provider-ini
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [3.49.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.48.0...v3.49.0) (2022-01-29)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package @aws-sdk/credential-provider-ini
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# [3.48.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.47.2...v3.48.0) (2022-01-22)
|
|
34
|
+
|
|
35
|
+
**Note:** Version bump only for package @aws-sdk/credential-provider-ini
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
6
41
|
## [3.47.2](https://github.com/aws/aws-sdk-js-v3/compare/v3.47.1...v3.47.2) (2022-01-21)
|
|
7
42
|
|
|
8
43
|
**Note:** Version bump only for package @aws-sdk/credential-provider-ini
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromIni = void 0;
|
|
4
|
+
const util_credentials_1 = require("@aws-sdk/util-credentials");
|
|
5
|
+
const resolveProfileData_1 = require("./resolveProfileData");
|
|
6
|
+
const fromIni = (init = {}) => async () => {
|
|
7
|
+
const profiles = await util_credentials_1.parseKnownFiles(init);
|
|
8
|
+
return resolveProfileData_1.resolveProfileData(util_credentials_1.getMasterProfileName(init), profiles, init);
|
|
9
|
+
};
|
|
10
|
+
exports.fromIni = fromIni;
|
package/dist-cjs/index.js
CHANGED
|
@@ -1,105 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const credential_provider_imds_1 = require("@aws-sdk/credential-provider-imds");
|
|
6
|
-
const credential_provider_sso_1 = require("@aws-sdk/credential-provider-sso");
|
|
7
|
-
const credential_provider_web_identity_1 = require("@aws-sdk/credential-provider-web-identity");
|
|
8
|
-
const property_provider_1 = require("@aws-sdk/property-provider");
|
|
9
|
-
const util_credentials_1 = require("@aws-sdk/util-credentials");
|
|
10
|
-
const isStaticCredsProfile = (arg) => Boolean(arg) &&
|
|
11
|
-
typeof arg === "object" &&
|
|
12
|
-
typeof arg.aws_access_key_id === "string" &&
|
|
13
|
-
typeof arg.aws_secret_access_key === "string" &&
|
|
14
|
-
["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1;
|
|
15
|
-
const isWebIdentityProfile = (arg) => Boolean(arg) &&
|
|
16
|
-
typeof arg === "object" &&
|
|
17
|
-
typeof arg.web_identity_token_file === "string" &&
|
|
18
|
-
typeof arg.role_arn === "string" &&
|
|
19
|
-
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1;
|
|
20
|
-
const isAssumeRoleProfile = (arg) => Boolean(arg) &&
|
|
21
|
-
typeof arg === "object" &&
|
|
22
|
-
typeof arg.role_arn === "string" &&
|
|
23
|
-
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 &&
|
|
24
|
-
["undefined", "string"].indexOf(typeof arg.external_id) > -1 &&
|
|
25
|
-
["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1;
|
|
26
|
-
const isAssumeRoleWithSourceProfile = (arg) => isAssumeRoleProfile(arg) && typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
|
|
27
|
-
const isAssumeRoleWithProviderProfile = (arg) => isAssumeRoleProfile(arg) && typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
|
|
28
|
-
const fromIni = (init = {}) => async () => {
|
|
29
|
-
const profiles = await util_credentials_1.parseKnownFiles(init);
|
|
30
|
-
return resolveProfileData(util_credentials_1.getMasterProfileName(init), profiles, init);
|
|
31
|
-
};
|
|
32
|
-
exports.fromIni = fromIni;
|
|
33
|
-
const resolveProfileData = async (profileName, profiles, options, visitedProfiles = {}) => {
|
|
34
|
-
const data = profiles[profileName];
|
|
35
|
-
if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) {
|
|
36
|
-
return resolveStaticCredentials(data);
|
|
37
|
-
}
|
|
38
|
-
if (isAssumeRoleWithSourceProfile(data) || isAssumeRoleWithProviderProfile(data)) {
|
|
39
|
-
const { external_id: ExternalId, mfa_serial, role_arn: RoleArn, role_session_name: RoleSessionName = "aws-sdk-js-" + Date.now(), source_profile, credential_source, } = data;
|
|
40
|
-
if (!options.roleAssumer) {
|
|
41
|
-
throw new property_provider_1.CredentialsProviderError(`Profile ${profileName} requires a role to be assumed, but no` + ` role assumption callback was provided.`, false);
|
|
42
|
-
}
|
|
43
|
-
if (source_profile && source_profile in visitedProfiles) {
|
|
44
|
-
throw new property_provider_1.CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile` +
|
|
45
|
-
` ${util_credentials_1.getMasterProfileName(options)}. Profiles visited: ` +
|
|
46
|
-
Object.keys(visitedProfiles).join(", "), false);
|
|
47
|
-
}
|
|
48
|
-
const sourceCreds = source_profile
|
|
49
|
-
? resolveProfileData(source_profile, profiles, options, {
|
|
50
|
-
...visitedProfiles,
|
|
51
|
-
[source_profile]: true,
|
|
52
|
-
})
|
|
53
|
-
: resolveCredentialSource(credential_source, profileName)();
|
|
54
|
-
const params = { RoleArn, RoleSessionName, ExternalId };
|
|
55
|
-
if (mfa_serial) {
|
|
56
|
-
if (!options.mfaCodeProvider) {
|
|
57
|
-
throw new property_provider_1.CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication,` + ` but no MFA code callback was provided.`, false);
|
|
58
|
-
}
|
|
59
|
-
params.SerialNumber = mfa_serial;
|
|
60
|
-
params.TokenCode = await options.mfaCodeProvider(mfa_serial);
|
|
61
|
-
}
|
|
62
|
-
return options.roleAssumer(await sourceCreds, params);
|
|
63
|
-
}
|
|
64
|
-
if (isStaticCredsProfile(data)) {
|
|
65
|
-
return resolveStaticCredentials(data);
|
|
66
|
-
}
|
|
67
|
-
if (isWebIdentityProfile(data)) {
|
|
68
|
-
return resolveWebIdentityCredentials(data, options);
|
|
69
|
-
}
|
|
70
|
-
if (credential_provider_sso_1.isSsoProfile(data)) {
|
|
71
|
-
const { sso_start_url, sso_account_id, sso_region, sso_role_name } = credential_provider_sso_1.validateSsoProfile(data);
|
|
72
|
-
return credential_provider_sso_1.fromSSO({
|
|
73
|
-
ssoStartUrl: sso_start_url,
|
|
74
|
-
ssoAccountId: sso_account_id,
|
|
75
|
-
ssoRegion: sso_region,
|
|
76
|
-
ssoRoleName: sso_role_name,
|
|
77
|
-
})();
|
|
78
|
-
}
|
|
79
|
-
throw new property_provider_1.CredentialsProviderError(`Profile ${profileName} could not be found or parsed in shared` + ` credentials file.`);
|
|
80
|
-
};
|
|
81
|
-
const resolveCredentialSource = (credentialSource, profileName) => {
|
|
82
|
-
const sourceProvidersMap = {
|
|
83
|
-
EcsContainer: credential_provider_imds_1.fromContainerMetadata,
|
|
84
|
-
Ec2InstanceMetadata: credential_provider_imds_1.fromInstanceMetadata,
|
|
85
|
-
Environment: credential_provider_env_1.fromEnv,
|
|
86
|
-
};
|
|
87
|
-
if (credentialSource in sourceProvidersMap) {
|
|
88
|
-
return sourceProvidersMap[credentialSource]();
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
throw new property_provider_1.CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, ` +
|
|
92
|
-
`expected EcsContainer or Ec2InstanceMetadata or Environment.`);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
const resolveStaticCredentials = (profile) => Promise.resolve({
|
|
96
|
-
accessKeyId: profile.aws_access_key_id,
|
|
97
|
-
secretAccessKey: profile.aws_secret_access_key,
|
|
98
|
-
sessionToken: profile.aws_session_token,
|
|
99
|
-
});
|
|
100
|
-
const resolveWebIdentityCredentials = async (profile, options) => credential_provider_web_identity_1.fromTokenFile({
|
|
101
|
-
webIdentityTokenFile: profile.web_identity_token_file,
|
|
102
|
-
roleArn: profile.role_arn,
|
|
103
|
-
roleSessionName: profile.role_session_name,
|
|
104
|
-
roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
|
|
105
|
-
})();
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./fromIni"), exports);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveAssumeRoleCredentials = exports.isAssumeRoleProfile = void 0;
|
|
4
|
+
const property_provider_1 = require("@aws-sdk/property-provider");
|
|
5
|
+
const util_credentials_1 = require("@aws-sdk/util-credentials");
|
|
6
|
+
const resolveCredentialSource_1 = require("./resolveCredentialSource");
|
|
7
|
+
const resolveProfileData_1 = require("./resolveProfileData");
|
|
8
|
+
const isAssumeRoleProfile = (arg) => Boolean(arg) &&
|
|
9
|
+
typeof arg === "object" &&
|
|
10
|
+
typeof arg.role_arn === "string" &&
|
|
11
|
+
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 &&
|
|
12
|
+
["undefined", "string"].indexOf(typeof arg.external_id) > -1 &&
|
|
13
|
+
["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1 &&
|
|
14
|
+
(isAssumeRoleWithSourceProfile(arg) || isAssumeRoleWithProviderProfile(arg));
|
|
15
|
+
exports.isAssumeRoleProfile = isAssumeRoleProfile;
|
|
16
|
+
const isAssumeRoleWithSourceProfile = (arg) => typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
|
|
17
|
+
const isAssumeRoleWithProviderProfile = (arg) => typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
|
|
18
|
+
const resolveAssumeRoleCredentials = async (profileName, profiles, options, visitedProfiles = {}) => {
|
|
19
|
+
const data = profiles[profileName];
|
|
20
|
+
if (!options.roleAssumer) {
|
|
21
|
+
throw new property_provider_1.CredentialsProviderError(`Profile ${profileName} requires a role to be assumed, but no role assumption callback was provided.`, false);
|
|
22
|
+
}
|
|
23
|
+
const { source_profile } = data;
|
|
24
|
+
if (source_profile && source_profile in visitedProfiles) {
|
|
25
|
+
throw new property_provider_1.CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile` +
|
|
26
|
+
` ${util_credentials_1.getMasterProfileName(options)}. Profiles visited: ` +
|
|
27
|
+
Object.keys(visitedProfiles).join(", "), false);
|
|
28
|
+
}
|
|
29
|
+
const sourceCredsProvider = source_profile
|
|
30
|
+
? resolveProfileData_1.resolveProfileData(source_profile, profiles, options, {
|
|
31
|
+
...visitedProfiles,
|
|
32
|
+
[source_profile]: true,
|
|
33
|
+
})
|
|
34
|
+
: resolveCredentialSource_1.resolveCredentialSource(data.credential_source, profileName)();
|
|
35
|
+
const params = {
|
|
36
|
+
RoleArn: data.role_arn,
|
|
37
|
+
RoleSessionName: data.role_session_name || `aws-sdk-js-${Date.now()}`,
|
|
38
|
+
ExternalId: data.external_id,
|
|
39
|
+
};
|
|
40
|
+
const { mfa_serial } = data;
|
|
41
|
+
if (mfa_serial) {
|
|
42
|
+
if (!options.mfaCodeProvider) {
|
|
43
|
+
throw new property_provider_1.CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication, but no MFA code callback was provided.`, false);
|
|
44
|
+
}
|
|
45
|
+
params.SerialNumber = mfa_serial;
|
|
46
|
+
params.TokenCode = await options.mfaCodeProvider(mfa_serial);
|
|
47
|
+
}
|
|
48
|
+
const sourceCreds = await sourceCredsProvider;
|
|
49
|
+
return options.roleAssumer(sourceCreds, params);
|
|
50
|
+
};
|
|
51
|
+
exports.resolveAssumeRoleCredentials = resolveAssumeRoleCredentials;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveCredentialSource = void 0;
|
|
4
|
+
const credential_provider_env_1 = require("@aws-sdk/credential-provider-env");
|
|
5
|
+
const credential_provider_imds_1 = require("@aws-sdk/credential-provider-imds");
|
|
6
|
+
const property_provider_1 = require("@aws-sdk/property-provider");
|
|
7
|
+
const resolveCredentialSource = (credentialSource, profileName) => {
|
|
8
|
+
const sourceProvidersMap = {
|
|
9
|
+
EcsContainer: credential_provider_imds_1.fromContainerMetadata,
|
|
10
|
+
Ec2InstanceMetadata: credential_provider_imds_1.fromInstanceMetadata,
|
|
11
|
+
Environment: credential_provider_env_1.fromEnv,
|
|
12
|
+
};
|
|
13
|
+
if (credentialSource in sourceProvidersMap) {
|
|
14
|
+
return sourceProvidersMap[credentialSource]();
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
throw new property_provider_1.CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, ` +
|
|
18
|
+
`expected EcsContainer or Ec2InstanceMetadata or Environment.`);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.resolveCredentialSource = resolveCredentialSource;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveProfileData = void 0;
|
|
4
|
+
const property_provider_1 = require("@aws-sdk/property-provider");
|
|
5
|
+
const resolveAssumeRoleCredentials_1 = require("./resolveAssumeRoleCredentials");
|
|
6
|
+
const resolveSsoCredentials_1 = require("./resolveSsoCredentials");
|
|
7
|
+
const resolveStaticCredentials_1 = require("./resolveStaticCredentials");
|
|
8
|
+
const resolveWebIdentityCredentials_1 = require("./resolveWebIdentityCredentials");
|
|
9
|
+
const resolveProfileData = async (profileName, profiles, options, visitedProfiles = {}) => {
|
|
10
|
+
const data = profiles[profileName];
|
|
11
|
+
if (Object.keys(visitedProfiles).length > 0 && resolveStaticCredentials_1.isStaticCredsProfile(data)) {
|
|
12
|
+
return resolveStaticCredentials_1.resolveStaticCredentials(data);
|
|
13
|
+
}
|
|
14
|
+
if (resolveAssumeRoleCredentials_1.isAssumeRoleProfile(data)) {
|
|
15
|
+
return resolveAssumeRoleCredentials_1.resolveAssumeRoleCredentials(profileName, profiles, options, visitedProfiles);
|
|
16
|
+
}
|
|
17
|
+
if (resolveStaticCredentials_1.isStaticCredsProfile(data)) {
|
|
18
|
+
return resolveStaticCredentials_1.resolveStaticCredentials(data);
|
|
19
|
+
}
|
|
20
|
+
if (resolveWebIdentityCredentials_1.isWebIdentityProfile(data)) {
|
|
21
|
+
return resolveWebIdentityCredentials_1.resolveWebIdentityCredentials(data, options);
|
|
22
|
+
}
|
|
23
|
+
if (resolveSsoCredentials_1.isSsoProfile(data)) {
|
|
24
|
+
return resolveSsoCredentials_1.resolveSsoCredentials(data);
|
|
25
|
+
}
|
|
26
|
+
throw new property_provider_1.CredentialsProviderError(`Profile ${profileName} could not be found or parsed in shared credentials file.`);
|
|
27
|
+
};
|
|
28
|
+
exports.resolveProfileData = resolveProfileData;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveSsoCredentials = exports.isSsoProfile = void 0;
|
|
4
|
+
const credential_provider_sso_1 = require("@aws-sdk/credential-provider-sso");
|
|
5
|
+
var credential_provider_sso_2 = require("@aws-sdk/credential-provider-sso");
|
|
6
|
+
Object.defineProperty(exports, "isSsoProfile", { enumerable: true, get: function () { return credential_provider_sso_2.isSsoProfile; } });
|
|
7
|
+
const resolveSsoCredentials = (data) => {
|
|
8
|
+
const { sso_start_url, sso_account_id, sso_region, sso_role_name } = credential_provider_sso_1.validateSsoProfile(data);
|
|
9
|
+
return credential_provider_sso_1.fromSSO({
|
|
10
|
+
ssoStartUrl: sso_start_url,
|
|
11
|
+
ssoAccountId: sso_account_id,
|
|
12
|
+
ssoRegion: sso_region,
|
|
13
|
+
ssoRoleName: sso_role_name,
|
|
14
|
+
})();
|
|
15
|
+
};
|
|
16
|
+
exports.resolveSsoCredentials = resolveSsoCredentials;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveStaticCredentials = exports.isStaticCredsProfile = void 0;
|
|
4
|
+
const isStaticCredsProfile = (arg) => Boolean(arg) &&
|
|
5
|
+
typeof arg === "object" &&
|
|
6
|
+
typeof arg.aws_access_key_id === "string" &&
|
|
7
|
+
typeof arg.aws_secret_access_key === "string" &&
|
|
8
|
+
["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1;
|
|
9
|
+
exports.isStaticCredsProfile = isStaticCredsProfile;
|
|
10
|
+
const resolveStaticCredentials = (profile) => Promise.resolve({
|
|
11
|
+
accessKeyId: profile.aws_access_key_id,
|
|
12
|
+
secretAccessKey: profile.aws_secret_access_key,
|
|
13
|
+
sessionToken: profile.aws_session_token,
|
|
14
|
+
});
|
|
15
|
+
exports.resolveStaticCredentials = resolveStaticCredentials;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveWebIdentityCredentials = exports.isWebIdentityProfile = void 0;
|
|
4
|
+
const credential_provider_web_identity_1 = require("@aws-sdk/credential-provider-web-identity");
|
|
5
|
+
const isWebIdentityProfile = (arg) => Boolean(arg) &&
|
|
6
|
+
typeof arg === "object" &&
|
|
7
|
+
typeof arg.web_identity_token_file === "string" &&
|
|
8
|
+
typeof arg.role_arn === "string" &&
|
|
9
|
+
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1;
|
|
10
|
+
exports.isWebIdentityProfile = isWebIdentityProfile;
|
|
11
|
+
const resolveWebIdentityCredentials = async (profile, options) => credential_provider_web_identity_1.fromTokenFile({
|
|
12
|
+
webIdentityTokenFile: profile.web_identity_token_file,
|
|
13
|
+
roleArn: profile.role_arn,
|
|
14
|
+
roleSessionName: profile.role_session_name,
|
|
15
|
+
roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
|
|
16
|
+
})();
|
|
17
|
+
exports.resolveWebIdentityCredentials = resolveWebIdentityCredentials;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { getMasterProfileName, parseKnownFiles } from "@aws-sdk/util-credentials";
|
|
3
|
+
import { resolveProfileData } from "./resolveProfileData";
|
|
4
|
+
export var fromIni = function (init) {
|
|
5
|
+
if (init === void 0) { init = {}; }
|
|
6
|
+
return function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
7
|
+
var profiles;
|
|
8
|
+
return __generator(this, function (_a) {
|
|
9
|
+
switch (_a.label) {
|
|
10
|
+
case 0: return [4, parseKnownFiles(init)];
|
|
11
|
+
case 1:
|
|
12
|
+
profiles = _a.sent();
|
|
13
|
+
return [2, resolveProfileData(getMasterProfileName(init), profiles, init)];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}); };
|
|
17
|
+
};
|
package/dist-es/index.js
CHANGED
|
@@ -1,141 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { fromEnv } from "@aws-sdk/credential-provider-env";
|
|
3
|
-
import { fromContainerMetadata, fromInstanceMetadata } from "@aws-sdk/credential-provider-imds";
|
|
4
|
-
import { fromSSO, isSsoProfile, validateSsoProfile } from "@aws-sdk/credential-provider-sso";
|
|
5
|
-
import { fromTokenFile } from "@aws-sdk/credential-provider-web-identity";
|
|
6
|
-
import { CredentialsProviderError } from "@aws-sdk/property-provider";
|
|
7
|
-
import { getMasterProfileName, parseKnownFiles } from "@aws-sdk/util-credentials";
|
|
8
|
-
var isStaticCredsProfile = function (arg) {
|
|
9
|
-
return Boolean(arg) &&
|
|
10
|
-
typeof arg === "object" &&
|
|
11
|
-
typeof arg.aws_access_key_id === "string" &&
|
|
12
|
-
typeof arg.aws_secret_access_key === "string" &&
|
|
13
|
-
["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1;
|
|
14
|
-
};
|
|
15
|
-
var isWebIdentityProfile = function (arg) {
|
|
16
|
-
return Boolean(arg) &&
|
|
17
|
-
typeof arg === "object" &&
|
|
18
|
-
typeof arg.web_identity_token_file === "string" &&
|
|
19
|
-
typeof arg.role_arn === "string" &&
|
|
20
|
-
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1;
|
|
21
|
-
};
|
|
22
|
-
var isAssumeRoleProfile = function (arg) {
|
|
23
|
-
return Boolean(arg) &&
|
|
24
|
-
typeof arg === "object" &&
|
|
25
|
-
typeof arg.role_arn === "string" &&
|
|
26
|
-
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 &&
|
|
27
|
-
["undefined", "string"].indexOf(typeof arg.external_id) > -1 &&
|
|
28
|
-
["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1;
|
|
29
|
-
};
|
|
30
|
-
var isAssumeRoleWithSourceProfile = function (arg) {
|
|
31
|
-
return isAssumeRoleProfile(arg) && typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
|
|
32
|
-
};
|
|
33
|
-
var isAssumeRoleWithProviderProfile = function (arg) {
|
|
34
|
-
return isAssumeRoleProfile(arg) && typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
|
|
35
|
-
};
|
|
36
|
-
export var fromIni = function (init) {
|
|
37
|
-
if (init === void 0) { init = {}; }
|
|
38
|
-
return function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
39
|
-
var profiles;
|
|
40
|
-
return __generator(this, function (_a) {
|
|
41
|
-
switch (_a.label) {
|
|
42
|
-
case 0: return [4, parseKnownFiles(init)];
|
|
43
|
-
case 1:
|
|
44
|
-
profiles = _a.sent();
|
|
45
|
-
return [2, resolveProfileData(getMasterProfileName(init), profiles, init)];
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}); };
|
|
49
|
-
};
|
|
50
|
-
var resolveProfileData = function (profileName, profiles, options, visitedProfiles) {
|
|
51
|
-
if (visitedProfiles === void 0) { visitedProfiles = {}; }
|
|
52
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
53
|
-
var data, ExternalId, mfa_serial, RoleArn, _a, RoleSessionName, source_profile, credential_source, sourceCreds, params, _b, _c, _d, _e, sso_start_url, sso_account_id, sso_region, sso_role_name;
|
|
54
|
-
var _f;
|
|
55
|
-
return __generator(this, function (_g) {
|
|
56
|
-
switch (_g.label) {
|
|
57
|
-
case 0:
|
|
58
|
-
data = profiles[profileName];
|
|
59
|
-
if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) {
|
|
60
|
-
return [2, resolveStaticCredentials(data)];
|
|
61
|
-
}
|
|
62
|
-
if (!(isAssumeRoleWithSourceProfile(data) || isAssumeRoleWithProviderProfile(data))) return [3, 4];
|
|
63
|
-
ExternalId = data.external_id, mfa_serial = data.mfa_serial, RoleArn = data.role_arn, _a = data.role_session_name, RoleSessionName = _a === void 0 ? "aws-sdk-js-" + Date.now() : _a, source_profile = data.source_profile, credential_source = data.credential_source;
|
|
64
|
-
if (!options.roleAssumer) {
|
|
65
|
-
throw new CredentialsProviderError("Profile " + profileName + " requires a role to be assumed, but no" + " role assumption callback was provided.", false);
|
|
66
|
-
}
|
|
67
|
-
if (source_profile && source_profile in visitedProfiles) {
|
|
68
|
-
throw new CredentialsProviderError("Detected a cycle attempting to resolve credentials for profile" +
|
|
69
|
-
(" " + getMasterProfileName(options) + ". Profiles visited: ") +
|
|
70
|
-
Object.keys(visitedProfiles).join(", "), false);
|
|
71
|
-
}
|
|
72
|
-
sourceCreds = source_profile
|
|
73
|
-
? resolveProfileData(source_profile, profiles, options, __assign(__assign({}, visitedProfiles), (_f = {}, _f[source_profile] = true, _f)))
|
|
74
|
-
: resolveCredentialSource(credential_source, profileName)();
|
|
75
|
-
params = { RoleArn: RoleArn, RoleSessionName: RoleSessionName, ExternalId: ExternalId };
|
|
76
|
-
if (!mfa_serial) return [3, 2];
|
|
77
|
-
if (!options.mfaCodeProvider) {
|
|
78
|
-
throw new CredentialsProviderError("Profile " + profileName + " requires multi-factor authentication," + " but no MFA code callback was provided.", false);
|
|
79
|
-
}
|
|
80
|
-
params.SerialNumber = mfa_serial;
|
|
81
|
-
_b = params;
|
|
82
|
-
return [4, options.mfaCodeProvider(mfa_serial)];
|
|
83
|
-
case 1:
|
|
84
|
-
_b.TokenCode = _g.sent();
|
|
85
|
-
_g.label = 2;
|
|
86
|
-
case 2:
|
|
87
|
-
_d = (_c = options).roleAssumer;
|
|
88
|
-
return [4, sourceCreds];
|
|
89
|
-
case 3: return [2, _d.apply(_c, [_g.sent(), params])];
|
|
90
|
-
case 4:
|
|
91
|
-
if (isStaticCredsProfile(data)) {
|
|
92
|
-
return [2, resolveStaticCredentials(data)];
|
|
93
|
-
}
|
|
94
|
-
if (isWebIdentityProfile(data)) {
|
|
95
|
-
return [2, resolveWebIdentityCredentials(data, options)];
|
|
96
|
-
}
|
|
97
|
-
if (isSsoProfile(data)) {
|
|
98
|
-
_e = validateSsoProfile(data), sso_start_url = _e.sso_start_url, sso_account_id = _e.sso_account_id, sso_region = _e.sso_region, sso_role_name = _e.sso_role_name;
|
|
99
|
-
return [2, fromSSO({
|
|
100
|
-
ssoStartUrl: sso_start_url,
|
|
101
|
-
ssoAccountId: sso_account_id,
|
|
102
|
-
ssoRegion: sso_region,
|
|
103
|
-
ssoRoleName: sso_role_name,
|
|
104
|
-
})()];
|
|
105
|
-
}
|
|
106
|
-
throw new CredentialsProviderError("Profile " + profileName + " could not be found or parsed in shared" + " credentials file.");
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
var resolveCredentialSource = function (credentialSource, profileName) {
|
|
112
|
-
var sourceProvidersMap = {
|
|
113
|
-
EcsContainer: fromContainerMetadata,
|
|
114
|
-
Ec2InstanceMetadata: fromInstanceMetadata,
|
|
115
|
-
Environment: fromEnv,
|
|
116
|
-
};
|
|
117
|
-
if (credentialSource in sourceProvidersMap) {
|
|
118
|
-
return sourceProvidersMap[credentialSource]();
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
throw new CredentialsProviderError("Unsupported credential source in profile " + profileName + ". Got " + credentialSource + ", " +
|
|
122
|
-
"expected EcsContainer or Ec2InstanceMetadata or Environment.");
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
var resolveStaticCredentials = function (profile) {
|
|
126
|
-
return Promise.resolve({
|
|
127
|
-
accessKeyId: profile.aws_access_key_id,
|
|
128
|
-
secretAccessKey: profile.aws_secret_access_key,
|
|
129
|
-
sessionToken: profile.aws_session_token,
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
var resolveWebIdentityCredentials = function (profile, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
133
|
-
return __generator(this, function (_a) {
|
|
134
|
-
return [2, fromTokenFile({
|
|
135
|
-
webIdentityTokenFile: profile.web_identity_token_file,
|
|
136
|
-
roleArn: profile.role_arn,
|
|
137
|
-
roleSessionName: profile.role_session_name,
|
|
138
|
-
roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
|
|
139
|
-
})()];
|
|
140
|
-
});
|
|
141
|
-
}); };
|
|
1
|
+
export * from "./fromIni";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { __assign, __awaiter, __generator } from "tslib";
|
|
2
|
+
import { CredentialsProviderError } from "@aws-sdk/property-provider";
|
|
3
|
+
import { getMasterProfileName } from "@aws-sdk/util-credentials";
|
|
4
|
+
import { resolveCredentialSource } from "./resolveCredentialSource";
|
|
5
|
+
import { resolveProfileData } from "./resolveProfileData";
|
|
6
|
+
export var isAssumeRoleProfile = function (arg) {
|
|
7
|
+
return Boolean(arg) &&
|
|
8
|
+
typeof arg === "object" &&
|
|
9
|
+
typeof arg.role_arn === "string" &&
|
|
10
|
+
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 &&
|
|
11
|
+
["undefined", "string"].indexOf(typeof arg.external_id) > -1 &&
|
|
12
|
+
["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1 &&
|
|
13
|
+
(isAssumeRoleWithSourceProfile(arg) || isAssumeRoleWithProviderProfile(arg));
|
|
14
|
+
};
|
|
15
|
+
var isAssumeRoleWithSourceProfile = function (arg) {
|
|
16
|
+
return typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
|
|
17
|
+
};
|
|
18
|
+
var isAssumeRoleWithProviderProfile = function (arg) {
|
|
19
|
+
return typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
|
|
20
|
+
};
|
|
21
|
+
export var resolveAssumeRoleCredentials = function (profileName, profiles, options, visitedProfiles) {
|
|
22
|
+
if (visitedProfiles === void 0) { visitedProfiles = {}; }
|
|
23
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
24
|
+
var data, source_profile, sourceCredsProvider, params, mfa_serial, _a, sourceCreds;
|
|
25
|
+
var _b;
|
|
26
|
+
return __generator(this, function (_c) {
|
|
27
|
+
switch (_c.label) {
|
|
28
|
+
case 0:
|
|
29
|
+
data = profiles[profileName];
|
|
30
|
+
if (!options.roleAssumer) {
|
|
31
|
+
throw new CredentialsProviderError("Profile " + profileName + " requires a role to be assumed, but no role assumption callback was provided.", false);
|
|
32
|
+
}
|
|
33
|
+
source_profile = data.source_profile;
|
|
34
|
+
if (source_profile && source_profile in visitedProfiles) {
|
|
35
|
+
throw new CredentialsProviderError("Detected a cycle attempting to resolve credentials for profile" +
|
|
36
|
+
(" " + getMasterProfileName(options) + ". Profiles visited: ") +
|
|
37
|
+
Object.keys(visitedProfiles).join(", "), false);
|
|
38
|
+
}
|
|
39
|
+
sourceCredsProvider = source_profile
|
|
40
|
+
? resolveProfileData(source_profile, profiles, options, __assign(__assign({}, visitedProfiles), (_b = {}, _b[source_profile] = true, _b)))
|
|
41
|
+
: resolveCredentialSource(data.credential_source, profileName)();
|
|
42
|
+
params = {
|
|
43
|
+
RoleArn: data.role_arn,
|
|
44
|
+
RoleSessionName: data.role_session_name || "aws-sdk-js-" + Date.now(),
|
|
45
|
+
ExternalId: data.external_id,
|
|
46
|
+
};
|
|
47
|
+
mfa_serial = data.mfa_serial;
|
|
48
|
+
if (!mfa_serial) return [3, 2];
|
|
49
|
+
if (!options.mfaCodeProvider) {
|
|
50
|
+
throw new CredentialsProviderError("Profile " + profileName + " requires multi-factor authentication, but no MFA code callback was provided.", false);
|
|
51
|
+
}
|
|
52
|
+
params.SerialNumber = mfa_serial;
|
|
53
|
+
_a = params;
|
|
54
|
+
return [4, options.mfaCodeProvider(mfa_serial)];
|
|
55
|
+
case 1:
|
|
56
|
+
_a.TokenCode = _c.sent();
|
|
57
|
+
_c.label = 2;
|
|
58
|
+
case 2: return [4, sourceCredsProvider];
|
|
59
|
+
case 3:
|
|
60
|
+
sourceCreds = _c.sent();
|
|
61
|
+
return [2, options.roleAssumer(sourceCreds, params)];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { fromEnv } from "@aws-sdk/credential-provider-env";
|
|
2
|
+
import { fromContainerMetadata, fromInstanceMetadata } from "@aws-sdk/credential-provider-imds";
|
|
3
|
+
import { CredentialsProviderError } from "@aws-sdk/property-provider";
|
|
4
|
+
export var resolveCredentialSource = function (credentialSource, profileName) {
|
|
5
|
+
var sourceProvidersMap = {
|
|
6
|
+
EcsContainer: fromContainerMetadata,
|
|
7
|
+
Ec2InstanceMetadata: fromInstanceMetadata,
|
|
8
|
+
Environment: fromEnv,
|
|
9
|
+
};
|
|
10
|
+
if (credentialSource in sourceProvidersMap) {
|
|
11
|
+
return sourceProvidersMap[credentialSource]();
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
throw new CredentialsProviderError("Unsupported credential source in profile " + profileName + ". Got " + credentialSource + ", " +
|
|
15
|
+
"expected EcsContainer or Ec2InstanceMetadata or Environment.");
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { CredentialsProviderError } from "@aws-sdk/property-provider";
|
|
3
|
+
import { isAssumeRoleProfile, resolveAssumeRoleCredentials } from "./resolveAssumeRoleCredentials";
|
|
4
|
+
import { isSsoProfile, resolveSsoCredentials } from "./resolveSsoCredentials";
|
|
5
|
+
import { isStaticCredsProfile, resolveStaticCredentials } from "./resolveStaticCredentials";
|
|
6
|
+
import { isWebIdentityProfile, resolveWebIdentityCredentials } from "./resolveWebIdentityCredentials";
|
|
7
|
+
export var resolveProfileData = function (profileName, profiles, options, visitedProfiles) {
|
|
8
|
+
if (visitedProfiles === void 0) { visitedProfiles = {}; }
|
|
9
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
10
|
+
var data;
|
|
11
|
+
return __generator(this, function (_a) {
|
|
12
|
+
data = profiles[profileName];
|
|
13
|
+
if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) {
|
|
14
|
+
return [2, resolveStaticCredentials(data)];
|
|
15
|
+
}
|
|
16
|
+
if (isAssumeRoleProfile(data)) {
|
|
17
|
+
return [2, resolveAssumeRoleCredentials(profileName, profiles, options, visitedProfiles)];
|
|
18
|
+
}
|
|
19
|
+
if (isStaticCredsProfile(data)) {
|
|
20
|
+
return [2, resolveStaticCredentials(data)];
|
|
21
|
+
}
|
|
22
|
+
if (isWebIdentityProfile(data)) {
|
|
23
|
+
return [2, resolveWebIdentityCredentials(data, options)];
|
|
24
|
+
}
|
|
25
|
+
if (isSsoProfile(data)) {
|
|
26
|
+
return [2, resolveSsoCredentials(data)];
|
|
27
|
+
}
|
|
28
|
+
throw new CredentialsProviderError("Profile " + profileName + " could not be found or parsed in shared credentials file.");
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { fromSSO, validateSsoProfile } from "@aws-sdk/credential-provider-sso";
|
|
2
|
+
export { isSsoProfile } from "@aws-sdk/credential-provider-sso";
|
|
3
|
+
export var resolveSsoCredentials = function (data) {
|
|
4
|
+
var _a = validateSsoProfile(data), sso_start_url = _a.sso_start_url, sso_account_id = _a.sso_account_id, sso_region = _a.sso_region, sso_role_name = _a.sso_role_name;
|
|
5
|
+
return fromSSO({
|
|
6
|
+
ssoStartUrl: sso_start_url,
|
|
7
|
+
ssoAccountId: sso_account_id,
|
|
8
|
+
ssoRegion: sso_region,
|
|
9
|
+
ssoRoleName: sso_role_name,
|
|
10
|
+
})();
|
|
11
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export var isStaticCredsProfile = function (arg) {
|
|
2
|
+
return Boolean(arg) &&
|
|
3
|
+
typeof arg === "object" &&
|
|
4
|
+
typeof arg.aws_access_key_id === "string" &&
|
|
5
|
+
typeof arg.aws_secret_access_key === "string" &&
|
|
6
|
+
["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1;
|
|
7
|
+
};
|
|
8
|
+
export var resolveStaticCredentials = function (profile) {
|
|
9
|
+
return Promise.resolve({
|
|
10
|
+
accessKeyId: profile.aws_access_key_id,
|
|
11
|
+
secretAccessKey: profile.aws_secret_access_key,
|
|
12
|
+
sessionToken: profile.aws_session_token,
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { fromTokenFile } from "@aws-sdk/credential-provider-web-identity";
|
|
3
|
+
export var isWebIdentityProfile = function (arg) {
|
|
4
|
+
return Boolean(arg) &&
|
|
5
|
+
typeof arg === "object" &&
|
|
6
|
+
typeof arg.web_identity_token_file === "string" &&
|
|
7
|
+
typeof arg.role_arn === "string" &&
|
|
8
|
+
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1;
|
|
9
|
+
};
|
|
10
|
+
export var resolveWebIdentityCredentials = function (profile, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11
|
+
return __generator(this, function (_a) {
|
|
12
|
+
return [2, fromTokenFile({
|
|
13
|
+
webIdentityTokenFile: profile.web_identity_token_file,
|
|
14
|
+
roleArn: profile.role_arn,
|
|
15
|
+
roleSessionName: profile.role_session_name,
|
|
16
|
+
roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
|
|
17
|
+
})()];
|
|
18
|
+
});
|
|
19
|
+
}); };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AssumeRoleWithWebIdentityParams } from "@aws-sdk/credential-provider-web-identity";
|
|
2
|
+
import { CredentialProvider, Credentials } from "@aws-sdk/types";
|
|
3
|
+
import { SourceProfileInit } from "@aws-sdk/util-credentials";
|
|
4
|
+
import { AssumeRoleParams } from "./resolveAssumeRoleCredentials";
|
|
5
|
+
export interface FromIniInit extends SourceProfileInit {
|
|
6
|
+
/**
|
|
7
|
+
* A function that returns a promise fulfilled with an MFA token code for
|
|
8
|
+
* the provided MFA Serial code. If a profile requires an MFA code and
|
|
9
|
+
* `mfaCodeProvider` is not a valid function, the credential provider
|
|
10
|
+
* promise will be rejected.
|
|
11
|
+
*
|
|
12
|
+
* @param mfaSerial The serial code of the MFA device specified.
|
|
13
|
+
*/
|
|
14
|
+
mfaCodeProvider?: (mfaSerial: string) => Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* A function that assumes a role and returns a promise fulfilled with
|
|
17
|
+
* credentials for the assumed role.
|
|
18
|
+
*
|
|
19
|
+
* @param sourceCreds The credentials with which to assume a role.
|
|
20
|
+
* @param params
|
|
21
|
+
*/
|
|
22
|
+
roleAssumer?: (sourceCreds: Credentials, params: AssumeRoleParams) => Promise<Credentials>;
|
|
23
|
+
/**
|
|
24
|
+
* A function that assumes a role with web identity and returns a promise fulfilled with
|
|
25
|
+
* credentials for the assumed role.
|
|
26
|
+
*
|
|
27
|
+
* @param sourceCreds The credentials with which to assume a role.
|
|
28
|
+
* @param params
|
|
29
|
+
*/
|
|
30
|
+
roleAssumerWithWebIdentity?: (params: AssumeRoleWithWebIdentityParams) => Promise<Credentials>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates a credential provider that will read from ini files and supports
|
|
34
|
+
* role assumption and multi-factor authentication.
|
|
35
|
+
*/
|
|
36
|
+
export declare const fromIni: (init?: FromIniInit) => CredentialProvider;
|
package/dist-types/index.d.ts
CHANGED
|
@@ -1,63 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { CredentialProvider, Credentials } from "@aws-sdk/types";
|
|
3
|
-
import { SourceProfileInit } from "@aws-sdk/util-credentials";
|
|
4
|
-
/**
|
|
5
|
-
* @see http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/STS.html#assumeRole-property
|
|
6
|
-
* TODO update the above to link to V3 docs
|
|
7
|
-
*/
|
|
8
|
-
export interface AssumeRoleParams {
|
|
9
|
-
/**
|
|
10
|
-
* The identifier of the role to be assumed.
|
|
11
|
-
*/
|
|
12
|
-
RoleArn: string;
|
|
13
|
-
/**
|
|
14
|
-
* A name for the assumed role session.
|
|
15
|
-
*/
|
|
16
|
-
RoleSessionName: string;
|
|
17
|
-
/**
|
|
18
|
-
* A unique identifier that is used by third parties when assuming roles in
|
|
19
|
-
* their customers' accounts.
|
|
20
|
-
*/
|
|
21
|
-
ExternalId?: string;
|
|
22
|
-
/**
|
|
23
|
-
* The identification number of the MFA device that is associated with the
|
|
24
|
-
* user who is making the `AssumeRole` call.
|
|
25
|
-
*/
|
|
26
|
-
SerialNumber?: string;
|
|
27
|
-
/**
|
|
28
|
-
* The value provided by the MFA device.
|
|
29
|
-
*/
|
|
30
|
-
TokenCode?: string;
|
|
31
|
-
}
|
|
32
|
-
export interface FromIniInit extends SourceProfileInit {
|
|
33
|
-
/**
|
|
34
|
-
* A function that returns a promise fulfilled with an MFA token code for
|
|
35
|
-
* the provided MFA Serial code. If a profile requires an MFA code and
|
|
36
|
-
* `mfaCodeProvider` is not a valid function, the credential provider
|
|
37
|
-
* promise will be rejected.
|
|
38
|
-
*
|
|
39
|
-
* @param mfaSerial The serial code of the MFA device specified.
|
|
40
|
-
*/
|
|
41
|
-
mfaCodeProvider?: (mfaSerial: string) => Promise<string>;
|
|
42
|
-
/**
|
|
43
|
-
* A function that assumes a role and returns a promise fulfilled with
|
|
44
|
-
* credentials for the assumed role.
|
|
45
|
-
*
|
|
46
|
-
* @param sourceCreds The credentials with which to assume a role.
|
|
47
|
-
* @param params
|
|
48
|
-
*/
|
|
49
|
-
roleAssumer?: (sourceCreds: Credentials, params: AssumeRoleParams) => Promise<Credentials>;
|
|
50
|
-
/**
|
|
51
|
-
* A function that assumes a role with web identity and returns a promise fulfilled with
|
|
52
|
-
* credentials for the assumed role.
|
|
53
|
-
*
|
|
54
|
-
* @param sourceCreds The credentials with which to assume a role.
|
|
55
|
-
* @param params
|
|
56
|
-
*/
|
|
57
|
-
roleAssumerWithWebIdentity?: (params: AssumeRoleWithWebIdentityParams) => Promise<Credentials>;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Creates a credential provider that will read from ini files and supports
|
|
61
|
-
* role assumption and multi-factor authentication.
|
|
62
|
-
*/
|
|
63
|
-
export declare const fromIni: (init?: FromIniInit) => CredentialProvider;
|
|
1
|
+
export * from "./fromIni";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ParsedIniData } from "@aws-sdk/shared-ini-file-loader";
|
|
2
|
+
import { FromIniInit } from "./fromIni";
|
|
3
|
+
/**
|
|
4
|
+
* @see http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/STS.html#assumeRole-property
|
|
5
|
+
* TODO update the above to link to V3 docs
|
|
6
|
+
*/
|
|
7
|
+
export interface AssumeRoleParams {
|
|
8
|
+
/**
|
|
9
|
+
* The identifier of the role to be assumed.
|
|
10
|
+
*/
|
|
11
|
+
RoleArn: string;
|
|
12
|
+
/**
|
|
13
|
+
* A name for the assumed role session.
|
|
14
|
+
*/
|
|
15
|
+
RoleSessionName: string;
|
|
16
|
+
/**
|
|
17
|
+
* A unique identifier that is used by third parties when assuming roles in
|
|
18
|
+
* their customers' accounts.
|
|
19
|
+
*/
|
|
20
|
+
ExternalId?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The identification number of the MFA device that is associated with the
|
|
23
|
+
* user who is making the `AssumeRole` call.
|
|
24
|
+
*/
|
|
25
|
+
SerialNumber?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The value provided by the MFA device.
|
|
28
|
+
*/
|
|
29
|
+
TokenCode?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const isAssumeRoleProfile: (arg: any) => boolean;
|
|
32
|
+
export declare const resolveAssumeRoleCredentials: (profileName: string, profiles: ParsedIniData, options: FromIniInit, visitedProfiles?: {
|
|
33
|
+
[profileName: string]: true;
|
|
34
|
+
}) => Promise<import("@aws-sdk/types").Credentials>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CredentialProvider } from "@aws-sdk/types";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the `credential_source` entry from the profile, and return the
|
|
4
|
+
* credential providers respectively. No memoization is needed for the
|
|
5
|
+
* credential source providers because memoization should be added outside the
|
|
6
|
+
* fromIni() provider. The source credential needs to be refreshed every time
|
|
7
|
+
* fromIni() is called.
|
|
8
|
+
*/
|
|
9
|
+
export declare const resolveCredentialSource: (credentialSource: string, profileName: string) => CredentialProvider;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ParsedIniData } from "@aws-sdk/shared-ini-file-loader";
|
|
2
|
+
import { Credentials } from "@aws-sdk/types";
|
|
3
|
+
import { FromIniInit } from "./fromIni";
|
|
4
|
+
export declare const resolveProfileData: (profileName: string, profiles: ParsedIniData, options: FromIniInit, visitedProfiles?: {
|
|
5
|
+
[profileName: string]: true;
|
|
6
|
+
}) => Promise<Credentials>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Profile } from "@aws-sdk/shared-ini-file-loader";
|
|
2
|
+
import { Credentials } from "@aws-sdk/types";
|
|
3
|
+
export interface StaticCredsProfile extends Profile {
|
|
4
|
+
aws_access_key_id: string;
|
|
5
|
+
aws_secret_access_key: string;
|
|
6
|
+
aws_session_token?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const isStaticCredsProfile: (arg: any) => arg is StaticCredsProfile;
|
|
9
|
+
export declare const resolveStaticCredentials: (profile: StaticCredsProfile) => Promise<Credentials>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Profile } from "@aws-sdk/shared-ini-file-loader";
|
|
2
|
+
import { Credentials } from "@aws-sdk/types";
|
|
3
|
+
import { FromIniInit } from "./fromIni";
|
|
4
|
+
export interface WebIdentityProfile extends Profile {
|
|
5
|
+
web_identity_token_file: string;
|
|
6
|
+
role_arn: string;
|
|
7
|
+
role_session_name?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const isWebIdentityProfile: (arg: any) => arg is WebIdentityProfile;
|
|
10
|
+
export declare const resolveWebIdentityCredentials: (profile: WebIdentityProfile, options: FromIniInit) => Promise<Credentials>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AssumeRoleWithWebIdentityParams } from "@aws-sdk/credential-provider-web-identity";
|
|
2
|
+
import { CredentialProvider, Credentials } from "@aws-sdk/types";
|
|
3
|
+
import { SourceProfileInit } from "@aws-sdk/util-credentials";
|
|
4
|
+
import { AssumeRoleParams } from "./resolveAssumeRoleCredentials";
|
|
5
|
+
export interface FromIniInit extends SourceProfileInit {
|
|
6
|
+
|
|
7
|
+
mfaCodeProvider?: (mfaSerial: string) => Promise<string>;
|
|
8
|
+
|
|
9
|
+
roleAssumer?: (sourceCreds: Credentials, params: AssumeRoleParams) => Promise<Credentials>;
|
|
10
|
+
|
|
11
|
+
roleAssumerWithWebIdentity?: (params: AssumeRoleWithWebIdentityParams) => Promise<Credentials>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export declare const fromIni: (init?: FromIniInit) => CredentialProvider;
|
|
@@ -1,26 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { CredentialProvider, Credentials } from "@aws-sdk/types";
|
|
3
|
-
import { SourceProfileInit } from "@aws-sdk/util-credentials";
|
|
4
|
-
|
|
5
|
-
export interface AssumeRoleParams {
|
|
6
|
-
|
|
7
|
-
RoleArn: string;
|
|
8
|
-
|
|
9
|
-
RoleSessionName: string;
|
|
10
|
-
|
|
11
|
-
ExternalId?: string;
|
|
12
|
-
|
|
13
|
-
SerialNumber?: string;
|
|
14
|
-
|
|
15
|
-
TokenCode?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface FromIniInit extends SourceProfileInit {
|
|
18
|
-
|
|
19
|
-
mfaCodeProvider?: (mfaSerial: string) => Promise<string>;
|
|
20
|
-
|
|
21
|
-
roleAssumer?: (sourceCreds: Credentials, params: AssumeRoleParams) => Promise<Credentials>;
|
|
22
|
-
|
|
23
|
-
roleAssumerWithWebIdentity?: (params: AssumeRoleWithWebIdentityParams) => Promise<Credentials>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export declare const fromIni: (init?: FromIniInit) => CredentialProvider;
|
|
1
|
+
export * from "./fromIni";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ParsedIniData } from "@aws-sdk/shared-ini-file-loader";
|
|
2
|
+
import { FromIniInit } from "./fromIni";
|
|
3
|
+
|
|
4
|
+
export interface AssumeRoleParams {
|
|
5
|
+
|
|
6
|
+
RoleArn: string;
|
|
7
|
+
|
|
8
|
+
RoleSessionName: string;
|
|
9
|
+
|
|
10
|
+
ExternalId?: string;
|
|
11
|
+
|
|
12
|
+
SerialNumber?: string;
|
|
13
|
+
|
|
14
|
+
TokenCode?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const isAssumeRoleProfile: (arg: any) => boolean;
|
|
17
|
+
export declare const resolveAssumeRoleCredentials: (profileName: string, profiles: ParsedIniData, options: FromIniInit, visitedProfiles?: {
|
|
18
|
+
[profileName: string]: true;
|
|
19
|
+
}) => Promise<import("@aws-sdk/types").Credentials>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ParsedIniData } from "@aws-sdk/shared-ini-file-loader";
|
|
2
|
+
import { Credentials } from "@aws-sdk/types";
|
|
3
|
+
import { FromIniInit } from "./fromIni";
|
|
4
|
+
export declare const resolveProfileData: (profileName: string, profiles: ParsedIniData, options: FromIniInit, visitedProfiles?: {
|
|
5
|
+
[profileName: string]: true;
|
|
6
|
+
}) => Promise<Credentials>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Profile } from "@aws-sdk/shared-ini-file-loader";
|
|
2
|
+
import { Credentials } from "@aws-sdk/types";
|
|
3
|
+
export interface StaticCredsProfile extends Profile {
|
|
4
|
+
aws_access_key_id: string;
|
|
5
|
+
aws_secret_access_key: string;
|
|
6
|
+
aws_session_token?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const isStaticCredsProfile: (arg: any) => arg is StaticCredsProfile;
|
|
9
|
+
export declare const resolveStaticCredentials: (profile: StaticCredsProfile) => Promise<Credentials>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Profile } from "@aws-sdk/shared-ini-file-loader";
|
|
2
|
+
import { Credentials } from "@aws-sdk/types";
|
|
3
|
+
import { FromIniInit } from "./fromIni";
|
|
4
|
+
export interface WebIdentityProfile extends Profile {
|
|
5
|
+
web_identity_token_file: string;
|
|
6
|
+
role_arn: string;
|
|
7
|
+
role_session_name?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const isWebIdentityProfile: (arg: any) => arg is WebIdentityProfile;
|
|
10
|
+
export declare const resolveWebIdentityCredentials: (profile: WebIdentityProfile, options: FromIniInit) => Promise<Credentials>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/credential-provider-ini",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.51.0",
|
|
4
4
|
"description": "AWS credential provider that sources credentials from ~/.aws/credentials and ~/.aws/config",
|
|
5
5
|
"main": "./dist-cjs/index.js",
|
|
6
6
|
"module": "./dist-es/index.js",
|
|
@@ -23,18 +23,24 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "Apache-2.0",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@aws-sdk/credential-provider-env": "3.
|
|
27
|
-
"@aws-sdk/credential-provider-imds": "3.
|
|
28
|
-
"@aws-sdk/credential-provider-sso": "3.
|
|
29
|
-
"@aws-sdk/credential-provider-web-identity": "3.
|
|
30
|
-
"@aws-sdk/property-provider": "3.
|
|
31
|
-
"@aws-sdk/shared-ini-file-loader": "3.
|
|
32
|
-
"@aws-sdk/types": "3.
|
|
33
|
-
"@aws-sdk/util-credentials": "3.
|
|
26
|
+
"@aws-sdk/credential-provider-env": "3.50.0",
|
|
27
|
+
"@aws-sdk/credential-provider-imds": "3.51.0",
|
|
28
|
+
"@aws-sdk/credential-provider-sso": "3.51.0",
|
|
29
|
+
"@aws-sdk/credential-provider-web-identity": "3.50.0",
|
|
30
|
+
"@aws-sdk/property-provider": "3.50.0",
|
|
31
|
+
"@aws-sdk/shared-ini-file-loader": "3.51.0",
|
|
32
|
+
"@aws-sdk/types": "3.50.0",
|
|
33
|
+
"@aws-sdk/util-credentials": "3.51.0",
|
|
34
34
|
"tslib": "^2.3.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@
|
|
37
|
+
"@tsconfig/recommended": "1.0.1",
|
|
38
|
+
"@types/node": "^10.0.0",
|
|
39
|
+
"concurrently": "7.0.0",
|
|
40
|
+
"downlevel-dts": "0.7.0",
|
|
41
|
+
"rimraf": "3.0.2",
|
|
42
|
+
"typedoc": "0.19.2",
|
|
43
|
+
"typescript": "~4.3.5"
|
|
38
44
|
},
|
|
39
45
|
"types": "./dist-types/index.d.ts",
|
|
40
46
|
"engines": {
|