@aws-sdk/credential-provider-ini 3.712.0 → 3.713.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/dist-cjs/index.js +25 -13
- package/dist-es/fromIni.js +10 -1
- package/dist-es/resolveAssumeRoleCredentials.js +13 -10
- package/dist-types/fromIni.d.ts +3 -2
- package/dist-types/ts3.4/fromIni.d.ts +4 -7
- package/package.json +12 -10
package/dist-cjs/index.js
CHANGED
|
@@ -100,28 +100,31 @@ var isCredentialSourceProfile = /* @__PURE__ */ __name((arg, { profile, logger }
|
|
|
100
100
|
return withProviderProfile;
|
|
101
101
|
}, "isCredentialSourceProfile");
|
|
102
102
|
var resolveAssumeRoleCredentials = /* @__PURE__ */ __name(async (profileName, profiles, options, visitedProfiles = {}) => {
|
|
103
|
-
var _a, _b;
|
|
103
|
+
var _a, _b, _c;
|
|
104
104
|
(_a = options.logger) == null ? void 0 : _a.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");
|
|
105
|
-
const
|
|
105
|
+
const profileData = profiles[profileName];
|
|
106
|
+
const { source_profile, region } = profileData;
|
|
106
107
|
if (!options.roleAssumer) {
|
|
107
108
|
const { getDefaultRoleAssumer } = await Promise.resolve().then(() => __toESM(require("@aws-sdk/client-sts")));
|
|
108
109
|
options.roleAssumer = getDefaultRoleAssumer(
|
|
109
110
|
{
|
|
110
111
|
...options.clientConfig,
|
|
111
112
|
credentialProviderLogger: options.logger,
|
|
112
|
-
parentClientConfig:
|
|
113
|
+
parentClientConfig: {
|
|
114
|
+
...options == null ? void 0 : options.parentClientConfig,
|
|
115
|
+
region: region ?? ((_b = options == null ? void 0 : options.parentClientConfig) == null ? void 0 : _b.region)
|
|
116
|
+
}
|
|
113
117
|
},
|
|
114
118
|
options.clientPlugins
|
|
115
119
|
);
|
|
116
120
|
}
|
|
117
|
-
const { source_profile } = data;
|
|
118
121
|
if (source_profile && source_profile in visitedProfiles) {
|
|
119
122
|
throw new import_property_provider.CredentialsProviderError(
|
|
120
123
|
`Detected a cycle attempting to resolve credentials for profile ${(0, import_shared_ini_file_loader.getProfileName)(options)}. Profiles visited: ` + Object.keys(visitedProfiles).join(", "),
|
|
121
124
|
{ logger: options.logger }
|
|
122
125
|
);
|
|
123
126
|
}
|
|
124
|
-
(
|
|
127
|
+
(_c = options.logger) == null ? void 0 : _c.debug(
|
|
125
128
|
`@aws-sdk/credential-provider-ini - finding credential resolver using ${source_profile ? `source_profile=[${source_profile}]` : `profile=[${profileName}]`}`
|
|
126
129
|
);
|
|
127
130
|
const sourceCredsProvider = source_profile ? resolveProfileData(
|
|
@@ -133,17 +136,17 @@ var resolveAssumeRoleCredentials = /* @__PURE__ */ __name(async (profileName, pr
|
|
|
133
136
|
[source_profile]: true
|
|
134
137
|
},
|
|
135
138
|
isCredentialSourceWithoutRoleArn(profiles[source_profile] ?? {})
|
|
136
|
-
) : (await resolveCredentialSource(
|
|
137
|
-
if (isCredentialSourceWithoutRoleArn(
|
|
139
|
+
) : (await resolveCredentialSource(profileData.credential_source, profileName, options.logger)(options))();
|
|
140
|
+
if (isCredentialSourceWithoutRoleArn(profileData)) {
|
|
138
141
|
return sourceCredsProvider.then((creds) => (0, import_client.setCredentialFeature)(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
|
|
139
142
|
} else {
|
|
140
143
|
const params = {
|
|
141
|
-
RoleArn:
|
|
142
|
-
RoleSessionName:
|
|
143
|
-
ExternalId:
|
|
144
|
-
DurationSeconds: parseInt(
|
|
144
|
+
RoleArn: profileData.role_arn,
|
|
145
|
+
RoleSessionName: profileData.role_session_name || `aws-sdk-js-${Date.now()}`,
|
|
146
|
+
ExternalId: profileData.external_id,
|
|
147
|
+
DurationSeconds: parseInt(profileData.duration_seconds || "3600", 10)
|
|
145
148
|
};
|
|
146
|
-
const { mfa_serial } =
|
|
149
|
+
const { mfa_serial } = profileData;
|
|
147
150
|
if (mfa_serial) {
|
|
148
151
|
if (!options.mfaCodeProvider) {
|
|
149
152
|
throw new import_property_provider.CredentialsProviderError(
|
|
@@ -251,8 +254,17 @@ var resolveProfileData = /* @__PURE__ */ __name(async (profileName, profiles, op
|
|
|
251
254
|
}, "resolveProfileData");
|
|
252
255
|
|
|
253
256
|
// src/fromIni.ts
|
|
254
|
-
var fromIni = /* @__PURE__ */ __name((
|
|
257
|
+
var fromIni = /* @__PURE__ */ __name((_init = {}) => async ({ callerClientConfig } = {}) => {
|
|
255
258
|
var _a;
|
|
259
|
+
const init = {
|
|
260
|
+
..._init
|
|
261
|
+
};
|
|
262
|
+
if (callerClientConfig == null ? void 0 : callerClientConfig.region) {
|
|
263
|
+
init.parentClientConfig = {
|
|
264
|
+
region: callerClientConfig.region,
|
|
265
|
+
..._init.parentClientConfig
|
|
266
|
+
};
|
|
267
|
+
}
|
|
256
268
|
(_a = init.logger) == null ? void 0 : _a.debug("@aws-sdk/credential-provider-ini - fromIni");
|
|
257
269
|
const profiles = await (0, import_shared_ini_file_loader.parseKnownFiles)(init);
|
|
258
270
|
return resolveProfileData((0, import_shared_ini_file_loader.getProfileName)(init), profiles, init);
|
package/dist-es/fromIni.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { getProfileName, parseKnownFiles } from "@smithy/shared-ini-file-loader";
|
|
2
2
|
import { resolveProfileData } from "./resolveProfileData";
|
|
3
|
-
export const fromIni = (
|
|
3
|
+
export const fromIni = (_init = {}) => async ({ callerClientConfig } = {}) => {
|
|
4
|
+
const init = {
|
|
5
|
+
..._init,
|
|
6
|
+
};
|
|
7
|
+
if (callerClientConfig?.region) {
|
|
8
|
+
init.parentClientConfig = {
|
|
9
|
+
region: callerClientConfig.region,
|
|
10
|
+
..._init.parentClientConfig,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
4
13
|
init.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");
|
|
5
14
|
const profiles = await parseKnownFiles(init);
|
|
6
15
|
return resolveProfileData(getProfileName(init), profiles, init);
|
|
@@ -28,16 +28,19 @@ const isCredentialSourceProfile = (arg, { profile, logger }) => {
|
|
|
28
28
|
};
|
|
29
29
|
export const resolveAssumeRoleCredentials = async (profileName, profiles, options, visitedProfiles = {}) => {
|
|
30
30
|
options.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");
|
|
31
|
-
const
|
|
31
|
+
const profileData = profiles[profileName];
|
|
32
|
+
const { source_profile, region } = profileData;
|
|
32
33
|
if (!options.roleAssumer) {
|
|
33
34
|
const { getDefaultRoleAssumer } = await import("@aws-sdk/client-sts");
|
|
34
35
|
options.roleAssumer = getDefaultRoleAssumer({
|
|
35
36
|
...options.clientConfig,
|
|
36
37
|
credentialProviderLogger: options.logger,
|
|
37
|
-
parentClientConfig:
|
|
38
|
+
parentClientConfig: {
|
|
39
|
+
...options?.parentClientConfig,
|
|
40
|
+
region: region ?? options?.parentClientConfig?.region,
|
|
41
|
+
},
|
|
38
42
|
}, options.clientPlugins);
|
|
39
43
|
}
|
|
40
|
-
const { source_profile } = data;
|
|
41
44
|
if (source_profile && source_profile in visitedProfiles) {
|
|
42
45
|
throw new CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile` +
|
|
43
46
|
` ${getProfileName(options)}. Profiles visited: ` +
|
|
@@ -49,18 +52,18 @@ export const resolveAssumeRoleCredentials = async (profileName, profiles, option
|
|
|
49
52
|
...visitedProfiles,
|
|
50
53
|
[source_profile]: true,
|
|
51
54
|
}, isCredentialSourceWithoutRoleArn(profiles[source_profile] ?? {}))
|
|
52
|
-
: (await resolveCredentialSource(
|
|
53
|
-
if (isCredentialSourceWithoutRoleArn(
|
|
55
|
+
: (await resolveCredentialSource(profileData.credential_source, profileName, options.logger)(options))();
|
|
56
|
+
if (isCredentialSourceWithoutRoleArn(profileData)) {
|
|
54
57
|
return sourceCredsProvider.then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
|
|
55
58
|
}
|
|
56
59
|
else {
|
|
57
60
|
const params = {
|
|
58
|
-
RoleArn:
|
|
59
|
-
RoleSessionName:
|
|
60
|
-
ExternalId:
|
|
61
|
-
DurationSeconds: parseInt(
|
|
61
|
+
RoleArn: profileData.role_arn,
|
|
62
|
+
RoleSessionName: profileData.role_session_name || `aws-sdk-js-${Date.now()}`,
|
|
63
|
+
ExternalId: profileData.external_id,
|
|
64
|
+
DurationSeconds: parseInt(profileData.duration_seconds || "3600", 10),
|
|
62
65
|
};
|
|
63
|
-
const { mfa_serial } =
|
|
66
|
+
const { mfa_serial } = profileData;
|
|
64
67
|
if (mfa_serial) {
|
|
65
68
|
if (!options.mfaCodeProvider) {
|
|
66
69
|
throw new CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication, but no MFA code callback was provided.`, { logger: options.logger, tryNextLink: false });
|
package/dist-types/fromIni.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AssumeRoleWithWebIdentityParams } from "@aws-sdk/credential-provider-web-identity";
|
|
2
2
|
import type { CredentialProviderOptions } from "@aws-sdk/types";
|
|
3
|
+
import type { RuntimeConfigAwsCredentialIdentityProvider } from "@aws-sdk/types";
|
|
3
4
|
import { SourceProfileInit } from "@smithy/shared-ini-file-loader";
|
|
4
|
-
import type { AwsCredentialIdentity,
|
|
5
|
+
import type { AwsCredentialIdentity, Pluggable } from "@smithy/types";
|
|
5
6
|
import { AssumeRoleParams } from "./resolveAssumeRoleCredentials";
|
|
6
7
|
/**
|
|
7
8
|
* @public
|
|
@@ -46,4 +47,4 @@ export interface FromIniInit extends SourceProfileInit, CredentialProviderOption
|
|
|
46
47
|
* Creates a credential provider that will read from ini files and supports
|
|
47
48
|
* role assumption and multi-factor authentication.
|
|
48
49
|
*/
|
|
49
|
-
export declare const fromIni: (
|
|
50
|
+
export declare const fromIni: (_init?: FromIniInit) => RuntimeConfigAwsCredentialIdentityProvider;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { AssumeRoleWithWebIdentityParams } from "@aws-sdk/credential-provider-web-identity";
|
|
2
2
|
import { CredentialProviderOptions } from "@aws-sdk/types";
|
|
3
|
+
import { RuntimeConfigAwsCredentialIdentityProvider } from "@aws-sdk/types";
|
|
3
4
|
import { SourceProfileInit } from "@smithy/shared-ini-file-loader";
|
|
4
|
-
import {
|
|
5
|
-
AwsCredentialIdentity,
|
|
6
|
-
AwsCredentialIdentityProvider,
|
|
7
|
-
Pluggable,
|
|
8
|
-
} from "@smithy/types";
|
|
5
|
+
import { AwsCredentialIdentity, Pluggable } from "@smithy/types";
|
|
9
6
|
import { AssumeRoleParams } from "./resolveAssumeRoleCredentials";
|
|
10
7
|
export interface FromIniInit
|
|
11
8
|
extends SourceProfileInit,
|
|
@@ -22,5 +19,5 @@ export interface FromIniInit
|
|
|
22
19
|
clientPlugins?: Pluggable<any, any>[];
|
|
23
20
|
}
|
|
24
21
|
export declare const fromIni: (
|
|
25
|
-
|
|
26
|
-
) =>
|
|
22
|
+
_init?: FromIniInit
|
|
23
|
+
) => RuntimeConfigAwsCredentialIdentityProvider;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/credential-provider-ini",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.713.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",
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
|
|
14
14
|
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
|
|
15
15
|
"test": "yarn g:vitest run",
|
|
16
|
-
"test:watch": "yarn g:vitest watch"
|
|
16
|
+
"test:watch": "yarn g:vitest watch",
|
|
17
|
+
"test:integration": "yarn g:vitest run -c vitest.config.integ.ts",
|
|
18
|
+
"test:integration:watch": "yarn g:vitest watch -c vitest.config.integ.ts"
|
|
17
19
|
},
|
|
18
20
|
"keywords": [
|
|
19
21
|
"aws",
|
|
@@ -25,13 +27,13 @@
|
|
|
25
27
|
},
|
|
26
28
|
"license": "Apache-2.0",
|
|
27
29
|
"dependencies": {
|
|
28
|
-
"@aws-sdk/core": "3.
|
|
29
|
-
"@aws-sdk/credential-provider-env": "3.
|
|
30
|
-
"@aws-sdk/credential-provider-http": "3.
|
|
31
|
-
"@aws-sdk/credential-provider-process": "3.
|
|
32
|
-
"@aws-sdk/credential-provider-sso": "3.
|
|
33
|
-
"@aws-sdk/credential-provider-web-identity": "3.
|
|
34
|
-
"@aws-sdk/types": "3.
|
|
30
|
+
"@aws-sdk/core": "3.713.0",
|
|
31
|
+
"@aws-sdk/credential-provider-env": "3.713.0",
|
|
32
|
+
"@aws-sdk/credential-provider-http": "3.713.0",
|
|
33
|
+
"@aws-sdk/credential-provider-process": "3.713.0",
|
|
34
|
+
"@aws-sdk/credential-provider-sso": "3.713.0",
|
|
35
|
+
"@aws-sdk/credential-provider-web-identity": "3.713.0",
|
|
36
|
+
"@aws-sdk/types": "3.713.0",
|
|
35
37
|
"@smithy/credential-provider-imds": "^3.2.8",
|
|
36
38
|
"@smithy/property-provider": "^3.1.11",
|
|
37
39
|
"@smithy/shared-ini-file-loader": "^3.1.12",
|
|
@@ -47,7 +49,7 @@
|
|
|
47
49
|
"typescript": "~4.9.5"
|
|
48
50
|
},
|
|
49
51
|
"peerDependencies": {
|
|
50
|
-
"@aws-sdk/client-sts": "^3.
|
|
52
|
+
"@aws-sdk/client-sts": "^3.713.0"
|
|
51
53
|
},
|
|
52
54
|
"types": "./dist-types/index.d.ts",
|
|
53
55
|
"engines": {
|