@aws-sdk/credential-provider-process 3.183.0 → 3.186.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.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06)
7
+
8
+ **Note:** Version bump only for package @aws-sdk/credential-provider-process
9
+
10
+
11
+
12
+
13
+
6
14
  # [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)
7
15
 
8
16
  **Note:** Version bump only for package @aws-sdk/credential-provider-process
@@ -1,6 +1,17 @@
1
+ import { __awaiter, __generator } from "tslib";
1
2
  import { getProfileName, parseKnownFiles } from "@aws-sdk/shared-ini-file-loader";
2
3
  import { resolveProcessCredentials } from "./resolveProcessCredentials";
3
- export const fromProcess = (init = {}) => async () => {
4
- const profiles = await parseKnownFiles(init);
5
- return resolveProcessCredentials(getProfileName(init), profiles);
4
+ export var fromProcess = 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, resolveProcessCredentials(getProfileName(init), profiles)];
14
+ }
15
+ });
16
+ }); };
6
17
  };
@@ -1,21 +1,17 @@
1
- export const getValidatedProcessCredentials = (profileName, data) => {
1
+ import { __assign } from "tslib";
2
+ export var getValidatedProcessCredentials = function (profileName, data) {
2
3
  if (data.Version !== 1) {
3
- throw Error(`Profile ${profileName} credential_process did not return Version 1.`);
4
+ throw Error("Profile ".concat(profileName, " credential_process did not return Version 1."));
4
5
  }
5
6
  if (data.AccessKeyId === undefined || data.SecretAccessKey === undefined) {
6
- throw Error(`Profile ${profileName} credential_process returned invalid credentials.`);
7
+ throw Error("Profile ".concat(profileName, " credential_process returned invalid credentials."));
7
8
  }
8
9
  if (data.Expiration) {
9
- const currentTime = new Date();
10
- const expireTime = new Date(data.Expiration);
10
+ var currentTime = new Date();
11
+ var expireTime = new Date(data.Expiration);
11
12
  if (expireTime < currentTime) {
12
- throw Error(`Profile ${profileName} credential_process returned expired credentials.`);
13
+ throw Error("Profile ".concat(profileName, " credential_process returned expired credentials."));
13
14
  }
14
15
  }
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
- };
16
+ return __assign(__assign({ accessKeyId: data.AccessKeyId, secretAccessKey: data.SecretAccessKey }, (data.SessionToken && { sessionToken: data.SessionToken })), (data.Expiration && { expiration: new Date(data.Expiration) }));
21
17
  };
@@ -1,33 +1,40 @@
1
+ import { __awaiter, __generator } from "tslib";
1
2
  import { CredentialsProviderError } from "@aws-sdk/property-provider";
2
3
  import { exec } from "child_process";
3
4
  import { promisify } from "util";
4
5
  import { getValidatedProcessCredentials } from "./getValidatedProcessCredentials";
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;
6
+ export var resolveProcessCredentials = function (profileName, profiles) { return __awaiter(void 0, void 0, void 0, function () {
7
+ var profile, credentialProcess, execPromise, stdout, data, error_1;
8
+ return __generator(this, function (_a) {
9
+ switch (_a.label) {
10
+ case 0:
11
+ profile = profiles[profileName];
12
+ if (!profiles[profileName]) return [3, 7];
13
+ credentialProcess = profile["credential_process"];
14
+ if (!(credentialProcess !== undefined)) return [3, 5];
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;
14
23
  try {
15
24
  data = JSON.parse(stdout.trim());
16
25
  }
17
- catch {
18
- throw Error(`Profile ${profileName} credential_process returned invalid JSON.`);
26
+ catch (_b) {
27
+ throw Error("Profile ".concat(profileName, " credential_process returned invalid JSON."));
19
28
  }
20
- return getValidatedProcessCredentials(profileName, data);
21
- }
22
- catch (error) {
23
- throw new CredentialsProviderError(error.message);
24
- }
29
+ return [2, getValidatedProcessCredentials(profileName, data)];
30
+ case 3:
31
+ error_1 = _a.sent();
32
+ throw new CredentialsProviderError(error_1.message);
33
+ case 4: return [3, 6];
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];
25
38
  }
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
- };
39
+ });
40
+ }); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/credential-provider-process",
3
- "version": "3.183.0",
3
+ "version": "3.186.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.183.0",
28
- "@aws-sdk/shared-ini-file-loader": "3.183.0",
29
- "@aws-sdk/types": "3.183.0",
27
+ "@aws-sdk/property-provider": "3.186.0",
28
+ "@aws-sdk/shared-ini-file-loader": "3.186.0",
29
+ "@aws-sdk/types": "3.186.0",
30
30
  "tslib": "^2.3.1"
31
31
  },
32
32
  "devDependencies": {