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,241 @@
1
+ "use strict";
2
+ exports.id = 605;
3
+ exports.ids = [605];
4
+ exports.modules = {
5
+
6
+ /***/ 1509:
7
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8
+
9
+
10
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
11
+ exports.checkUrl = void 0;
12
+ const config_1 = __webpack_require__(47291);
13
+ const LOOPBACK_CIDR_IPv4 = "127.0.0.0/8";
14
+ const LOOPBACK_CIDR_IPv6 = "::1/128";
15
+ const ECS_CONTAINER_HOST = "169.254.170.2";
16
+ const EKS_CONTAINER_HOST_IPv4 = "169.254.170.23";
17
+ const EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]";
18
+ const checkUrl = (url, logger) => {
19
+ if (url.protocol === "https:") {
20
+ return;
21
+ }
22
+ if (url.hostname === ECS_CONTAINER_HOST ||
23
+ url.hostname === EKS_CONTAINER_HOST_IPv4 ||
24
+ url.hostname === EKS_CONTAINER_HOST_IPv6) {
25
+ return;
26
+ }
27
+ if (url.hostname.includes("[")) {
28
+ if (url.hostname === "[::1]" || url.hostname === "[0000:0000:0000:0000:0000:0000:0000:0001]") {
29
+ return;
30
+ }
31
+ }
32
+ else {
33
+ if (url.hostname === "localhost") {
34
+ return;
35
+ }
36
+ const ipComponents = url.hostname.split(".");
37
+ const inRange = (component) => {
38
+ const num = parseInt(component, 10);
39
+ return 0 <= num && num <= 255;
40
+ };
41
+ if (ipComponents[0] === "127" &&
42
+ inRange(ipComponents[1]) &&
43
+ inRange(ipComponents[2]) &&
44
+ inRange(ipComponents[3]) &&
45
+ ipComponents.length === 4) {
46
+ return;
47
+ }
48
+ }
49
+ throw new config_1.CredentialsProviderError(`URL not accepted. It must either be HTTPS or match one of the following:
50
+ - loopback CIDR 127.0.0.0/8 or [::1/128]
51
+ - ECS container host 169.254.170.2
52
+ - EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger });
53
+ };
54
+ exports.checkUrl = checkUrl;
55
+
56
+
57
+ /***/ }),
58
+
59
+ /***/ 68712:
60
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
61
+
62
+
63
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
64
+ exports.fromHttp = void 0;
65
+ const tslib_1 = __webpack_require__(61860);
66
+ const client_1 = __webpack_require__(5152);
67
+ const config_1 = __webpack_require__(47291);
68
+ const node_http_handler_1 = __webpack_require__(61279);
69
+ const promises_1 = tslib_1.__importDefault(__webpack_require__(51455));
70
+ const checkUrl_1 = __webpack_require__(1509);
71
+ const requestHelpers_1 = __webpack_require__(78914);
72
+ const retry_wrapper_1 = __webpack_require__(51122);
73
+ const AWS_CONTAINER_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
74
+ const DEFAULT_LINK_LOCAL_HOST = "http://169.254.170.2";
75
+ const AWS_CONTAINER_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
76
+ const AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE = "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE";
77
+ const AWS_CONTAINER_AUTHORIZATION_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
78
+ const fromHttp = (options = {}) => {
79
+ options.logger?.debug("@aws-sdk/credential-provider-http - fromHttp");
80
+ let host;
81
+ const relative = options.awsContainerCredentialsRelativeUri ?? process.env[AWS_CONTAINER_CREDENTIALS_RELATIVE_URI];
82
+ const full = options.awsContainerCredentialsFullUri ?? process.env[AWS_CONTAINER_CREDENTIALS_FULL_URI];
83
+ const token = options.awsContainerAuthorizationToken ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN];
84
+ const tokenFile = options.awsContainerAuthorizationTokenFile ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE];
85
+ const warn = options.logger?.constructor?.name === "NoOpLogger" || !options.logger?.warn
86
+ ? console.warn
87
+ : options.logger.warn.bind(options.logger);
88
+ if (relative && full) {
89
+ warn("@aws-sdk/credential-provider-http: " +
90
+ "you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri.");
91
+ warn("awsContainerCredentialsFullUri will take precedence.");
92
+ }
93
+ if (token && tokenFile) {
94
+ warn("@aws-sdk/credential-provider-http: " +
95
+ "you have set both awsContainerAuthorizationToken and awsContainerAuthorizationTokenFile.");
96
+ warn("awsContainerAuthorizationToken will take precedence.");
97
+ }
98
+ if (full) {
99
+ host = full;
100
+ }
101
+ else if (relative) {
102
+ host = `${DEFAULT_LINK_LOCAL_HOST}${relative}`;
103
+ }
104
+ else {
105
+ throw new config_1.CredentialsProviderError(`No HTTP credential provider host provided.
106
+ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.`, { logger: options.logger });
107
+ }
108
+ const url = new URL(host);
109
+ (0, checkUrl_1.checkUrl)(url, options.logger);
110
+ const requestHandler = node_http_handler_1.NodeHttpHandler.create({ connectionTimeout: options.timeout ?? 1000 });
111
+ const requestTimeout = options.timeout ?? 1000;
112
+ const provider = (0, retry_wrapper_1.retryWrapper)(async () => {
113
+ const request = (0, requestHelpers_1.createGetRequest)(url);
114
+ if (token) {
115
+ request.headers.Authorization = token;
116
+ }
117
+ else if (tokenFile) {
118
+ request.headers.Authorization = (await promises_1.default.readFile(tokenFile)).toString();
119
+ }
120
+ try {
121
+ const result = await requestHandler.handle(request, { requestTimeout });
122
+ return (0, requestHelpers_1.getCredentials)(result.response).then((creds) => (0, client_1.setCredentialFeature)(creds, "CREDENTIALS_HTTP", "z"));
123
+ }
124
+ catch (e) {
125
+ throw new config_1.CredentialsProviderError(String(e), { logger: options.logger });
126
+ }
127
+ }, options.maxRetries ?? 3, options.timeout ?? 1000);
128
+ return async () => {
129
+ try {
130
+ return await provider();
131
+ }
132
+ finally {
133
+ requestHandler.destroy?.();
134
+ }
135
+ };
136
+ };
137
+ exports.fromHttp = fromHttp;
138
+
139
+
140
+ /***/ }),
141
+
142
+ /***/ 78914:
143
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
144
+
145
+
146
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
147
+ exports.createGetRequest = createGetRequest;
148
+ exports.getCredentials = getCredentials;
149
+ const config_1 = __webpack_require__(47291);
150
+ const protocols_1 = __webpack_require__(93422);
151
+ const serde_1 = __webpack_require__(92430);
152
+ const serde_2 = __webpack_require__(92430);
153
+ function createGetRequest(url) {
154
+ return new protocols_1.HttpRequest({
155
+ protocol: url.protocol,
156
+ hostname: url.hostname,
157
+ port: Number(url.port),
158
+ path: url.pathname,
159
+ query: Array.from(url.searchParams.entries()).reduce((acc, [k, v]) => {
160
+ acc[k] = v;
161
+ return acc;
162
+ }, {}),
163
+ fragment: url.hash,
164
+ });
165
+ }
166
+ async function getCredentials(response, logger) {
167
+ const stream = (0, serde_2.sdkStreamMixin)(response.body);
168
+ const str = await stream.transformToString();
169
+ if (response.statusCode === 200) {
170
+ const parsed = JSON.parse(str);
171
+ if (typeof parsed.AccessKeyId !== "string" ||
172
+ typeof parsed.SecretAccessKey !== "string" ||
173
+ typeof parsed.Token !== "string" ||
174
+ typeof parsed.Expiration !== "string") {
175
+ throw new config_1.CredentialsProviderError("HTTP credential provider response not of the required format, an object matching: " +
176
+ "{ AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", { logger });
177
+ }
178
+ return {
179
+ accessKeyId: parsed.AccessKeyId,
180
+ secretAccessKey: parsed.SecretAccessKey,
181
+ sessionToken: parsed.Token,
182
+ expiration: (0, serde_1.parseRfc3339DateTime)(parsed.Expiration),
183
+ };
184
+ }
185
+ if (response.statusCode >= 400 && response.statusCode < 500) {
186
+ let parsedBody = {};
187
+ try {
188
+ parsedBody = JSON.parse(str);
189
+ }
190
+ catch (e) { }
191
+ throw Object.assign(new config_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger }), {
192
+ Code: parsedBody.Code,
193
+ Message: parsedBody.Message,
194
+ });
195
+ }
196
+ throw new config_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger });
197
+ }
198
+
199
+
200
+ /***/ }),
201
+
202
+ /***/ 51122:
203
+ /***/ ((__unused_webpack_module, exports) => {
204
+
205
+
206
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
207
+ exports.retryWrapper = void 0;
208
+ const retryWrapper = (toRetry, maxRetries, delayMs) => {
209
+ return async () => {
210
+ for (let i = 0; i < maxRetries; ++i) {
211
+ try {
212
+ return await toRetry();
213
+ }
214
+ catch (e) {
215
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
216
+ }
217
+ }
218
+ return await toRetry();
219
+ };
220
+ };
221
+ exports.retryWrapper = retryWrapper;
222
+
223
+
224
+ /***/ }),
225
+
226
+ /***/ 98605:
227
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
228
+
229
+
230
+
231
+ var fromHttp = __webpack_require__(68712);
232
+
233
+
234
+
235
+ exports.fromHttp = fromHttp.fromHttp;
236
+
237
+
238
+ /***/ })
239
+
240
+ };
241
+ ;