terratest 1.0.1

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.
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ exports.id = 360;
3
+ exports.ids = [360];
4
+ exports.modules = {
5
+
6
+ /***/ 75360:
7
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8
+
9
+
10
+
11
+ var config = __webpack_require__(47291);
12
+ var node_child_process = __webpack_require__(31421);
13
+ var node_util = __webpack_require__(57975);
14
+ var client = __webpack_require__(5152);
15
+
16
+ const getValidatedProcessCredentials = (profileName, data, profiles) => {
17
+ if (data.Version !== 1) {
18
+ throw Error(`Profile ${profileName} credential_process did not return Version 1.`);
19
+ }
20
+ if (data.AccessKeyId === undefined || data.SecretAccessKey === undefined) {
21
+ throw Error(`Profile ${profileName} credential_process returned invalid credentials.`);
22
+ }
23
+ if (data.Expiration) {
24
+ const currentTime = new Date();
25
+ const expireTime = new Date(data.Expiration);
26
+ if (expireTime < currentTime) {
27
+ throw Error(`Profile ${profileName} credential_process returned expired credentials.`);
28
+ }
29
+ }
30
+ let accountId = data.AccountId;
31
+ if (!accountId && profiles?.[profileName]?.aws_account_id) {
32
+ accountId = profiles[profileName].aws_account_id;
33
+ }
34
+ const credentials = {
35
+ accessKeyId: data.AccessKeyId,
36
+ secretAccessKey: data.SecretAccessKey,
37
+ ...(data.SessionToken && { sessionToken: data.SessionToken }),
38
+ ...(data.Expiration && { expiration: new Date(data.Expiration) }),
39
+ ...(data.CredentialScope && { credentialScope: data.CredentialScope }),
40
+ ...(accountId && { accountId }),
41
+ };
42
+ client.setCredentialFeature(credentials, "CREDENTIALS_PROCESS", "w");
43
+ return credentials;
44
+ };
45
+
46
+ const resolveProcessCredentials = async (profileName, profiles, logger) => {
47
+ const profile = profiles[profileName];
48
+ if (profiles[profileName]) {
49
+ const credentialProcess = profile["credential_process"];
50
+ if (credentialProcess !== undefined) {
51
+ const execPromise = node_util.promisify(config.externalDataInterceptor?.getTokenRecord?.().exec ?? node_child_process.exec);
52
+ try {
53
+ const { stdout } = await execPromise(credentialProcess);
54
+ let data;
55
+ try {
56
+ data = JSON.parse(stdout.trim());
57
+ }
58
+ catch {
59
+ throw Error(`Profile ${profileName} credential_process returned invalid JSON.`);
60
+ }
61
+ return getValidatedProcessCredentials(profileName, data, profiles);
62
+ }
63
+ catch (error) {
64
+ throw new config.CredentialsProviderError(error.message, { logger });
65
+ }
66
+ }
67
+ else {
68
+ throw new config.CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`, { logger });
69
+ }
70
+ }
71
+ else {
72
+ throw new config.CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`, {
73
+ logger,
74
+ });
75
+ }
76
+ };
77
+
78
+ const fromProcess = (init = {}) => async ({ callerClientConfig } = {}) => {
79
+ init.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");
80
+ const profiles = await config.parseKnownFiles(init);
81
+ return resolveProcessCredentials(config.getProfileName({
82
+ profile: init.profile ?? callerClientConfig?.profile,
83
+ }), profiles, init.logger);
84
+ };
85
+
86
+ exports.fromProcess = fromProcess;
87
+
88
+
89
+ /***/ })
90
+
91
+ };
92
+ ;