@aws-sdk/credential-provider-process 3.178.0 → 3.183.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
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-sdk/credential-provider-process
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [3.178.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.177.0...v3.178.0) (2022-09-23)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @aws-sdk/credential-provider-process
|
package/dist-es/fromProcess.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
1
|
import { getProfileName, parseKnownFiles } from "@aws-sdk/shared-ini-file-loader";
|
|
3
2
|
import { resolveProcessCredentials } from "./resolveProcessCredentials";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
return
|
|
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, resolveProcessCredentials(getProfileName(init), profiles)];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
}); };
|
|
3
|
+
export const fromProcess = (init = {}) => async () => {
|
|
4
|
+
const profiles = await parseKnownFiles(init);
|
|
5
|
+
return resolveProcessCredentials(getProfileName(init), profiles);
|
|
17
6
|
};
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
export var getValidatedProcessCredentials = function (profileName, data) {
|
|
1
|
+
export const getValidatedProcessCredentials = (profileName, data) => {
|
|
3
2
|
if (data.Version !== 1) {
|
|
4
|
-
throw Error(
|
|
3
|
+
throw Error(`Profile ${profileName} credential_process did not return Version 1.`);
|
|
5
4
|
}
|
|
6
5
|
if (data.AccessKeyId === undefined || data.SecretAccessKey === undefined) {
|
|
7
|
-
throw Error(
|
|
6
|
+
throw Error(`Profile ${profileName} credential_process returned invalid credentials.`);
|
|
8
7
|
}
|
|
9
8
|
if (data.Expiration) {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const currentTime = new Date();
|
|
10
|
+
const expireTime = new Date(data.Expiration);
|
|
12
11
|
if (expireTime < currentTime) {
|
|
13
|
-
throw Error(
|
|
12
|
+
throw Error(`Profile ${profileName} credential_process returned expired credentials.`);
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
|
-
return
|
|
15
|
+
return {
|
|
16
|
+
accessKeyId: data.AccessKeyId,
|
|
17
|
+
secretAccessKey: data.SecretAccessKey,
|
|
18
|
+
...(data.SessionToken && { sessionToken: data.SessionToken }),
|
|
19
|
+
...(data.Expiration && { expiration: new Date(data.Expiration) }),
|
|
20
|
+
};
|
|
17
21
|
};
|
|
@@ -1,40 +1,33 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
1
|
import { CredentialsProviderError } from "@aws-sdk/property-provider";
|
|
3
2
|
import { exec } from "child_process";
|
|
4
3
|
import { promisify } from "util";
|
|
5
4
|
import { getValidatedProcessCredentials } from "./getValidatedProcessCredentials";
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
execPromise = promisify(exec);
|
|
16
|
-
_a.label = 1;
|
|
17
|
-
case 1:
|
|
18
|
-
_a.trys.push([1, 3, , 4]);
|
|
19
|
-
return [4, execPromise(credentialProcess)];
|
|
20
|
-
case 2:
|
|
21
|
-
stdout = (_a.sent()).stdout;
|
|
22
|
-
data = void 0;
|
|
5
|
+
export const resolveProcessCredentials = async (profileName, profiles) => {
|
|
6
|
+
const profile = profiles[profileName];
|
|
7
|
+
if (profiles[profileName]) {
|
|
8
|
+
const credentialProcess = profile["credential_process"];
|
|
9
|
+
if (credentialProcess !== undefined) {
|
|
10
|
+
const execPromise = promisify(exec);
|
|
11
|
+
try {
|
|
12
|
+
const { stdout } = await execPromise(credentialProcess);
|
|
13
|
+
let data;
|
|
23
14
|
try {
|
|
24
15
|
data = JSON.parse(stdout.trim());
|
|
25
16
|
}
|
|
26
|
-
catch
|
|
27
|
-
throw Error(
|
|
17
|
+
catch {
|
|
18
|
+
throw Error(`Profile ${profileName} credential_process returned invalid JSON.`);
|
|
28
19
|
}
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
throw new CredentialsProviderError(
|
|
33
|
-
|
|
34
|
-
case 5: throw new CredentialsProviderError("Profile ".concat(profileName, " did not contain credential_process."));
|
|
35
|
-
case 6: return [3, 8];
|
|
36
|
-
case 7: throw new CredentialsProviderError("Profile ".concat(profileName, " could not be found in shared credentials file."));
|
|
37
|
-
case 8: return [2];
|
|
20
|
+
return getValidatedProcessCredentials(profileName, data);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw new CredentialsProviderError(error.message);
|
|
24
|
+
}
|
|
38
25
|
}
|
|
39
|
-
|
|
40
|
-
});
|
|
26
|
+
else {
|
|
27
|
+
throw new CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`);
|
|
32
|
+
}
|
|
33
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/credential-provider-process",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.183.0",
|
|
4
4
|
"description": "AWS credential provider that sources credential_process from ~/.aws/credentials and ~/.aws/config",
|
|
5
5
|
"main": "./dist-cjs/index.js",
|
|
6
6
|
"module": "./dist-es/index.js",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@aws-sdk/property-provider": "3.
|
|
28
|
-
"@aws-sdk/shared-ini-file-loader": "3.
|
|
29
|
-
"@aws-sdk/types": "3.
|
|
27
|
+
"@aws-sdk/property-provider": "3.183.0",
|
|
28
|
+
"@aws-sdk/shared-ini-file-loader": "3.183.0",
|
|
29
|
+
"@aws-sdk/types": "3.183.0",
|
|
30
30
|
"tslib": "^2.3.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|