@aws-sdk/credential-provider-process 3.50.0 → 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 +11 -0
- package/dist-cjs/ProcessCredentials.js +2 -0
- package/dist-cjs/fromProcess.js +10 -0
- package/dist-cjs/getValidatedProcessCredentials.js +25 -0
- package/dist-cjs/index.js +2 -68
- package/dist-cjs/resolveProcessCredentials.js +37 -0
- package/dist-es/ProcessCredentials.js +1 -0
- package/dist-es/fromProcess.js +17 -0
- package/dist-es/getValidatedProcessCredentials.js +17 -0
- package/dist-es/index.js +1 -82
- package/dist-es/resolveProcessCredentials.js +40 -0
- package/dist-types/ProcessCredentials.d.ts +7 -0
- package/dist-types/fromProcess.d.ts +9 -0
- package/dist-types/getValidatedProcessCredentials.d.ts +3 -0
- package/dist-types/index.d.ts +1 -13
- package/dist-types/resolveProcessCredentials.d.ts +3 -0
- package/dist-types/ts3.4/ProcessCredentials.d.ts +7 -0
- package/dist-types/ts3.4/fromProcess.d.ts +6 -0
- package/dist-types/ts3.4/getValidatedProcessCredentials.d.ts +3 -0
- package/dist-types/ts3.4/index.d.ts +1 -0
- package/dist-types/ts3.4/resolveProcessCredentials.d.ts +3 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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-process:** refactor into modular components ([#3287](https://github.com/aws/aws-sdk-js-v3/issues/3287)) ([2b64304](https://github.com/aws/aws-sdk-js-v3/commit/2b64304c17191b3ffad4965b8a88509ddf4e79c7))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [3.50.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.49.0...v3.50.0) (2022-02-08)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @aws-sdk/credential-provider-process
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromProcess = void 0;
|
|
4
|
+
const util_credentials_1 = require("@aws-sdk/util-credentials");
|
|
5
|
+
const resolveProcessCredentials_1 = require("./resolveProcessCredentials");
|
|
6
|
+
const fromProcess = (init = {}) => async () => {
|
|
7
|
+
const profiles = await util_credentials_1.parseKnownFiles(init);
|
|
8
|
+
return resolveProcessCredentials_1.resolveProcessCredentials(util_credentials_1.getMasterProfileName(init), profiles);
|
|
9
|
+
};
|
|
10
|
+
exports.fromProcess = fromProcess;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getValidatedProcessCredentials = void 0;
|
|
4
|
+
const getValidatedProcessCredentials = (profileName, data) => {
|
|
5
|
+
if (data.Version !== 1) {
|
|
6
|
+
throw Error(`Profile ${profileName} credential_process did not return Version 1.`);
|
|
7
|
+
}
|
|
8
|
+
if (data.AccessKeyId === undefined || data.SecretAccessKey === undefined) {
|
|
9
|
+
throw Error(`Profile ${profileName} credential_process returned invalid credentials.`);
|
|
10
|
+
}
|
|
11
|
+
if (data.Expiration) {
|
|
12
|
+
const currentTime = new Date();
|
|
13
|
+
const expireTime = new Date(data.Expiration);
|
|
14
|
+
if (expireTime < currentTime) {
|
|
15
|
+
throw Error(`Profile ${profileName} credential_process returned expired credentials.`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
accessKeyId: data.AccessKeyId,
|
|
20
|
+
secretAccessKey: data.SecretAccessKey,
|
|
21
|
+
...(data.SessionToken && { sessionToken: data.SessionToken }),
|
|
22
|
+
...(data.Expiration && { expiration: new Date(data.Expiration) }),
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.getValidatedProcessCredentials = getValidatedProcessCredentials;
|
package/dist-cjs/index.js
CHANGED
|
@@ -1,70 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const util_credentials_1 = require("@aws-sdk/util-credentials");
|
|
6
|
-
const child_process_1 = require("child_process");
|
|
7
|
-
exports.ENV_PROFILE = "AWS_PROFILE";
|
|
8
|
-
const fromProcess = (init = {}) => async () => {
|
|
9
|
-
const profiles = await util_credentials_1.parseKnownFiles(init);
|
|
10
|
-
return resolveProcessCredentials(util_credentials_1.getMasterProfileName(init), profiles);
|
|
11
|
-
};
|
|
12
|
-
exports.fromProcess = fromProcess;
|
|
13
|
-
const resolveProcessCredentials = async (profileName, profiles) => {
|
|
14
|
-
const profile = profiles[profileName];
|
|
15
|
-
if (profiles[profileName]) {
|
|
16
|
-
const credentialProcess = profile["credential_process"];
|
|
17
|
-
if (credentialProcess !== undefined) {
|
|
18
|
-
return await execPromise(credentialProcess)
|
|
19
|
-
.then((processResult) => {
|
|
20
|
-
let data;
|
|
21
|
-
try {
|
|
22
|
-
data = JSON.parse(processResult);
|
|
23
|
-
}
|
|
24
|
-
catch (_a) {
|
|
25
|
-
throw Error(`Profile ${profileName} credential_process returned invalid JSON.`);
|
|
26
|
-
}
|
|
27
|
-
const { Version: version, AccessKeyId: accessKeyId, SecretAccessKey: secretAccessKey, SessionToken: sessionToken, Expiration: expiration, } = data;
|
|
28
|
-
if (version !== 1) {
|
|
29
|
-
throw Error(`Profile ${profileName} credential_process did not return Version 1.`);
|
|
30
|
-
}
|
|
31
|
-
if (accessKeyId === undefined || secretAccessKey === undefined) {
|
|
32
|
-
throw Error(`Profile ${profileName} credential_process returned invalid credentials.`);
|
|
33
|
-
}
|
|
34
|
-
let expirationUnix;
|
|
35
|
-
if (expiration) {
|
|
36
|
-
const currentTime = new Date();
|
|
37
|
-
const expireTime = new Date(expiration);
|
|
38
|
-
if (expireTime < currentTime) {
|
|
39
|
-
throw Error(`Profile ${profileName} credential_process returned expired credentials.`);
|
|
40
|
-
}
|
|
41
|
-
expirationUnix = Math.floor(new Date(expiration).valueOf() / 1000);
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
accessKeyId,
|
|
45
|
-
secretAccessKey,
|
|
46
|
-
sessionToken,
|
|
47
|
-
expirationUnix,
|
|
48
|
-
};
|
|
49
|
-
})
|
|
50
|
-
.catch((error) => {
|
|
51
|
-
throw new property_provider_1.CredentialsProviderError(error.message);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
throw new property_provider_1.CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
throw new property_provider_1.CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const execPromise = (command) => new Promise(function (resolve, reject) {
|
|
63
|
-
child_process_1.exec(command, (error, stdout) => {
|
|
64
|
-
if (error) {
|
|
65
|
-
reject(error);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
resolve(stdout.trim());
|
|
69
|
-
});
|
|
70
|
-
});
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./fromProcess"), exports);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveProcessCredentials = void 0;
|
|
4
|
+
const property_provider_1 = require("@aws-sdk/property-provider");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const util_1 = require("util");
|
|
7
|
+
const getValidatedProcessCredentials_1 = require("./getValidatedProcessCredentials");
|
|
8
|
+
const resolveProcessCredentials = async (profileName, profiles) => {
|
|
9
|
+
const profile = profiles[profileName];
|
|
10
|
+
if (profiles[profileName]) {
|
|
11
|
+
const credentialProcess = profile["credential_process"];
|
|
12
|
+
if (credentialProcess !== undefined) {
|
|
13
|
+
const execPromise = util_1.promisify(child_process_1.exec);
|
|
14
|
+
try {
|
|
15
|
+
const { stdout } = await execPromise(credentialProcess);
|
|
16
|
+
let data;
|
|
17
|
+
try {
|
|
18
|
+
data = JSON.parse(stdout.trim());
|
|
19
|
+
}
|
|
20
|
+
catch (_a) {
|
|
21
|
+
throw Error(`Profile ${profileName} credential_process returned invalid JSON.`);
|
|
22
|
+
}
|
|
23
|
+
return getValidatedProcessCredentials_1.getValidatedProcessCredentials(profileName, data);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
throw new property_provider_1.CredentialsProviderError(error.message);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw new property_provider_1.CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
throw new property_provider_1.CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.resolveProcessCredentials = resolveProcessCredentials;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { getMasterProfileName, parseKnownFiles } from "@aws-sdk/util-credentials";
|
|
3
|
+
import { resolveProcessCredentials } from "./resolveProcessCredentials";
|
|
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(getMasterProfileName(init), profiles)];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}); };
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
export var getValidatedProcessCredentials = function (profileName, data) {
|
|
3
|
+
if (data.Version !== 1) {
|
|
4
|
+
throw Error("Profile " + profileName + " credential_process did not return Version 1.");
|
|
5
|
+
}
|
|
6
|
+
if (data.AccessKeyId === undefined || data.SecretAccessKey === undefined) {
|
|
7
|
+
throw Error("Profile " + profileName + " credential_process returned invalid credentials.");
|
|
8
|
+
}
|
|
9
|
+
if (data.Expiration) {
|
|
10
|
+
var currentTime = new Date();
|
|
11
|
+
var expireTime = new Date(data.Expiration);
|
|
12
|
+
if (expireTime < currentTime) {
|
|
13
|
+
throw Error("Profile " + profileName + " credential_process returned expired credentials.");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return __assign(__assign({ accessKeyId: data.AccessKeyId, secretAccessKey: data.SecretAccessKey }, (data.SessionToken && { sessionToken: data.SessionToken })), (data.Expiration && { expiration: new Date(data.Expiration) }));
|
|
17
|
+
};
|
package/dist-es/index.js
CHANGED
|
@@ -1,82 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { CredentialsProviderError } from "@aws-sdk/property-provider";
|
|
3
|
-
import { getMasterProfileName, parseKnownFiles } from "@aws-sdk/util-credentials";
|
|
4
|
-
import { exec } from "child_process";
|
|
5
|
-
export var ENV_PROFILE = "AWS_PROFILE";
|
|
6
|
-
export var fromProcess = function (init) {
|
|
7
|
-
if (init === void 0) { init = {}; }
|
|
8
|
-
return function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
9
|
-
var profiles;
|
|
10
|
-
return __generator(this, function (_a) {
|
|
11
|
-
switch (_a.label) {
|
|
12
|
-
case 0: return [4, parseKnownFiles(init)];
|
|
13
|
-
case 1:
|
|
14
|
-
profiles = _a.sent();
|
|
15
|
-
return [2, resolveProcessCredentials(getMasterProfileName(init), profiles)];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}); };
|
|
19
|
-
};
|
|
20
|
-
var resolveProcessCredentials = function (profileName, profiles) { return __awaiter(void 0, void 0, void 0, function () {
|
|
21
|
-
var profile, credentialProcess;
|
|
22
|
-
return __generator(this, function (_a) {
|
|
23
|
-
switch (_a.label) {
|
|
24
|
-
case 0:
|
|
25
|
-
profile = profiles[profileName];
|
|
26
|
-
if (!profiles[profileName]) return [3, 4];
|
|
27
|
-
credentialProcess = profile["credential_process"];
|
|
28
|
-
if (!(credentialProcess !== undefined)) return [3, 2];
|
|
29
|
-
return [4, execPromise(credentialProcess)
|
|
30
|
-
.then(function (processResult) {
|
|
31
|
-
var data;
|
|
32
|
-
try {
|
|
33
|
-
data = JSON.parse(processResult);
|
|
34
|
-
}
|
|
35
|
-
catch (_a) {
|
|
36
|
-
throw Error("Profile " + profileName + " credential_process returned invalid JSON.");
|
|
37
|
-
}
|
|
38
|
-
var version = data.Version, accessKeyId = data.AccessKeyId, secretAccessKey = data.SecretAccessKey, sessionToken = data.SessionToken, expiration = data.Expiration;
|
|
39
|
-
if (version !== 1) {
|
|
40
|
-
throw Error("Profile " + profileName + " credential_process did not return Version 1.");
|
|
41
|
-
}
|
|
42
|
-
if (accessKeyId === undefined || secretAccessKey === undefined) {
|
|
43
|
-
throw Error("Profile " + profileName + " credential_process returned invalid credentials.");
|
|
44
|
-
}
|
|
45
|
-
var expirationUnix;
|
|
46
|
-
if (expiration) {
|
|
47
|
-
var currentTime = new Date();
|
|
48
|
-
var expireTime = new Date(expiration);
|
|
49
|
-
if (expireTime < currentTime) {
|
|
50
|
-
throw Error("Profile " + profileName + " credential_process returned expired credentials.");
|
|
51
|
-
}
|
|
52
|
-
expirationUnix = Math.floor(new Date(expiration).valueOf() / 1000);
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
accessKeyId: accessKeyId,
|
|
56
|
-
secretAccessKey: secretAccessKey,
|
|
57
|
-
sessionToken: sessionToken,
|
|
58
|
-
expirationUnix: expirationUnix,
|
|
59
|
-
};
|
|
60
|
-
})
|
|
61
|
-
.catch(function (error) {
|
|
62
|
-
throw new CredentialsProviderError(error.message);
|
|
63
|
-
})];
|
|
64
|
-
case 1: return [2, _a.sent()];
|
|
65
|
-
case 2: throw new CredentialsProviderError("Profile " + profileName + " did not contain credential_process.");
|
|
66
|
-
case 3: return [3, 5];
|
|
67
|
-
case 4: throw new CredentialsProviderError("Profile " + profileName + " could not be found in shared credentials file.");
|
|
68
|
-
case 5: return [2];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}); };
|
|
72
|
-
var execPromise = function (command) {
|
|
73
|
-
return new Promise(function (resolve, reject) {
|
|
74
|
-
exec(command, function (error, stdout) {
|
|
75
|
-
if (error) {
|
|
76
|
-
reject(error);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
resolve(stdout.trim());
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
};
|
|
1
|
+
export * from "./fromProcess";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { CredentialsProviderError } from "@aws-sdk/property-provider";
|
|
3
|
+
import { exec } from "child_process";
|
|
4
|
+
import { promisify } from "util";
|
|
5
|
+
import { getValidatedProcessCredentials } from "./getValidatedProcessCredentials";
|
|
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;
|
|
23
|
+
try {
|
|
24
|
+
data = JSON.parse(stdout.trim());
|
|
25
|
+
}
|
|
26
|
+
catch (_b) {
|
|
27
|
+
throw Error("Profile " + profileName + " credential_process returned invalid JSON.");
|
|
28
|
+
}
|
|
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 " + profileName + " did not contain credential_process.");
|
|
35
|
+
case 6: return [3, 8];
|
|
36
|
+
case 7: throw new CredentialsProviderError("Profile " + profileName + " could not be found in shared credentials file.");
|
|
37
|
+
case 8: return [2];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}); };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CredentialProvider } from "@aws-sdk/types";
|
|
2
|
+
import { SourceProfileInit } from "@aws-sdk/util-credentials";
|
|
3
|
+
export interface FromProcessInit extends SourceProfileInit {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Creates a credential provider that will read from a credential_process specified
|
|
7
|
+
* in ini files.
|
|
8
|
+
*/
|
|
9
|
+
export declare const fromProcess: (init?: FromProcessInit) => CredentialProvider;
|
package/dist-types/index.d.ts
CHANGED
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { SourceProfileInit } from "@aws-sdk/util-credentials";
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export declare const ENV_PROFILE = "AWS_PROFILE";
|
|
7
|
-
export interface FromProcessInit extends SourceProfileInit {
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Creates a credential provider that will read from a credential_process specified
|
|
11
|
-
* in ini files.
|
|
12
|
-
*/
|
|
13
|
-
export declare const fromProcess: (init?: FromProcessInit) => CredentialProvider;
|
|
1
|
+
export * from "./fromProcess";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CredentialProvider } from "@aws-sdk/types";
|
|
2
|
+
import { SourceProfileInit } from "@aws-sdk/util-credentials";
|
|
3
|
+
export interface FromProcessInit extends SourceProfileInit {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export declare const fromProcess: (init?: FromProcessInit) => CredentialProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./fromProcess";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/credential-provider-process",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.51.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
|
"license": "Apache-2.0",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@aws-sdk/property-provider": "3.50.0",
|
|
27
|
-
"@aws-sdk/shared-ini-file-loader": "3.
|
|
27
|
+
"@aws-sdk/shared-ini-file-loader": "3.51.0",
|
|
28
28
|
"@aws-sdk/types": "3.50.0",
|
|
29
|
-
"@aws-sdk/util-credentials": "3.
|
|
29
|
+
"@aws-sdk/util-credentials": "3.51.0",
|
|
30
30
|
"tslib": "^2.3.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|