@digipair/skill-s3 0.127.1 → 0.128.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.
@@ -0,0 +1,3446 @@
1
+ import fs from 'fs/promises';
2
+ import { aP as escapeUri, K as fromBase64, J as toBase64, aQ as toHex, t as toUtf8, aR as fromArrayBuffer } from './index.esm3.js';
3
+ import { Readable, Writable } from 'stream';
4
+ import { Agent as Agent$1, request as request$1 } from 'http';
5
+ import { Agent, request } from 'https';
6
+ import 'buffer';
7
+ import 'path';
8
+ import 'os';
9
+ import 'node:fs/promises';
10
+ import 'crypto';
11
+ import 'node:stream';
12
+ import 'process';
13
+ import 'node:fs';
14
+ import 'zlib';
15
+
16
+ function setCredentialFeature(credentials, feature, value) {
17
+ if (!credentials.$source) {
18
+ credentials.$source = {};
19
+ }
20
+ credentials.$source[feature] = value;
21
+ return credentials;
22
+ }
23
+
24
+ function _array_like_to_array$2(arr, len) {
25
+ if (len == null || len > arr.length) len = arr.length;
26
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
27
+ return arr2;
28
+ }
29
+ function _array_without_holes(arr) {
30
+ if (Array.isArray(arr)) return _array_like_to_array$2(arr);
31
+ }
32
+ function _class_call_check$5(instance, Constructor) {
33
+ if (!(instance instanceof Constructor)) {
34
+ throw new TypeError("Cannot call a class as a function");
35
+ }
36
+ }
37
+ function _defineProperties$4(target, props) {
38
+ for(var i = 0; i < props.length; i++){
39
+ var descriptor = props[i];
40
+ descriptor.enumerable = descriptor.enumerable || false;
41
+ descriptor.configurable = true;
42
+ if ("value" in descriptor) descriptor.writable = true;
43
+ Object.defineProperty(target, descriptor.key, descriptor);
44
+ }
45
+ }
46
+ function _create_class$4(Constructor, protoProps, staticProps) {
47
+ if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
48
+ if (staticProps) _defineProperties$4(Constructor, staticProps);
49
+ return Constructor;
50
+ }
51
+ function _define_property$5(obj, key, value) {
52
+ if (key in obj) {
53
+ Object.defineProperty(obj, key, {
54
+ value: value,
55
+ enumerable: true,
56
+ configurable: true,
57
+ writable: true
58
+ });
59
+ } else {
60
+ obj[key] = value;
61
+ }
62
+ return obj;
63
+ }
64
+ function _iterable_to_array(iter) {
65
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
66
+ }
67
+ function _non_iterable_spread() {
68
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
69
+ }
70
+ function _object_spread$1(target) {
71
+ for(var i = 1; i < arguments.length; i++){
72
+ var source = arguments[i] != null ? arguments[i] : {};
73
+ var ownKeys = Object.keys(source);
74
+ if (typeof Object.getOwnPropertySymbols === "function") {
75
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
76
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
77
+ }));
78
+ }
79
+ ownKeys.forEach(function(key) {
80
+ _define_property$5(target, key, source[key]);
81
+ });
82
+ }
83
+ return target;
84
+ }
85
+ function ownKeys$1(object, enumerableOnly) {
86
+ var keys = Object.keys(object);
87
+ if (Object.getOwnPropertySymbols) {
88
+ var symbols = Object.getOwnPropertySymbols(object);
89
+ keys.push.apply(keys, symbols);
90
+ }
91
+ return keys;
92
+ }
93
+ function _object_spread_props$1(target, source) {
94
+ source = source != null ? source : {};
95
+ if (Object.getOwnPropertyDescriptors) {
96
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
97
+ } else {
98
+ ownKeys$1(Object(source)).forEach(function(key) {
99
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
100
+ });
101
+ }
102
+ return target;
103
+ }
104
+ function _to_consumable_array(arr) {
105
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread();
106
+ }
107
+ function _type_of$7(obj) {
108
+ "@swc/helpers - typeof";
109
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
110
+ }
111
+ function _unsupported_iterable_to_array$2(o, minLen) {
112
+ if (!o) return;
113
+ if (typeof o === "string") return _array_like_to_array$2(o, minLen);
114
+ var n = Object.prototype.toString.call(o).slice(8, -1);
115
+ if (n === "Object" && o.constructor) n = o.constructor.name;
116
+ if (n === "Map" || n === "Set") return Array.from(n);
117
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
118
+ }
119
+ var HttpRequest = /*#__PURE__*/ function() {
120
+ function HttpRequest(options) {
121
+ _class_call_check$5(this, HttpRequest);
122
+ _define_property$5(this, "method", void 0);
123
+ _define_property$5(this, "protocol", void 0);
124
+ _define_property$5(this, "hostname", void 0);
125
+ _define_property$5(this, "port", void 0);
126
+ _define_property$5(this, "path", void 0);
127
+ _define_property$5(this, "query", void 0);
128
+ _define_property$5(this, "headers", void 0);
129
+ _define_property$5(this, "username", void 0);
130
+ _define_property$5(this, "password", void 0);
131
+ _define_property$5(this, "fragment", void 0);
132
+ _define_property$5(this, "body", void 0);
133
+ this.method = options.method || "GET";
134
+ this.hostname = options.hostname || "localhost";
135
+ this.port = options.port;
136
+ this.query = options.query || {};
137
+ this.headers = options.headers || {};
138
+ this.body = options.body;
139
+ this.protocol = options.protocol ? options.protocol.slice(-1) !== ":" ? "".concat(options.protocol, ":") : options.protocol : "https:";
140
+ this.path = options.path ? options.path.charAt(0) !== "/" ? "/".concat(options.path) : options.path : "/";
141
+ this.username = options.username;
142
+ this.password = options.password;
143
+ this.fragment = options.fragment;
144
+ }
145
+ _create_class$4(HttpRequest, [
146
+ {
147
+ key: "clone",
148
+ value: function clone() {
149
+ return HttpRequest.clone(this);
150
+ }
151
+ }
152
+ ], [
153
+ {
154
+ key: "clone",
155
+ value: function clone(request) {
156
+ var cloned = new HttpRequest(_object_spread_props$1(_object_spread$1({}, request), {
157
+ headers: _object_spread$1({}, request.headers)
158
+ }));
159
+ if (cloned.query) {
160
+ cloned.query = cloneQuery(cloned.query);
161
+ }
162
+ return cloned;
163
+ }
164
+ },
165
+ {
166
+ key: "isInstance",
167
+ value: function isInstance(request) {
168
+ if (!request) {
169
+ return false;
170
+ }
171
+ var req = request;
172
+ return "method" in req && "protocol" in req && "hostname" in req && "path" in req && _type_of$7(req["query"]) === "object" && _type_of$7(req["headers"]) === "object";
173
+ }
174
+ }
175
+ ]);
176
+ return HttpRequest;
177
+ }();
178
+ function cloneQuery(query) {
179
+ return Object.keys(query).reduce(function(carry, paramName) {
180
+ var param = query[paramName];
181
+ return _object_spread_props$1(_object_spread$1({}, carry), _define_property$5({}, paramName, Array.isArray(param) ? _to_consumable_array(param) : param));
182
+ }, {});
183
+ }
184
+
185
+ function _class_call_check$4(instance, Constructor) {
186
+ if (!(instance instanceof Constructor)) {
187
+ throw new TypeError("Cannot call a class as a function");
188
+ }
189
+ }
190
+ function _defineProperties$3(target, props) {
191
+ for(var i = 0; i < props.length; i++){
192
+ var descriptor = props[i];
193
+ descriptor.enumerable = descriptor.enumerable || false;
194
+ descriptor.configurable = true;
195
+ if ("value" in descriptor) descriptor.writable = true;
196
+ Object.defineProperty(target, descriptor.key, descriptor);
197
+ }
198
+ }
199
+ function _create_class$3(Constructor, protoProps, staticProps) {
200
+ if (staticProps) _defineProperties$3(Constructor, staticProps);
201
+ return Constructor;
202
+ }
203
+ function _define_property$4(obj, key, value) {
204
+ if (key in obj) {
205
+ Object.defineProperty(obj, key, {
206
+ value: value,
207
+ enumerable: true,
208
+ configurable: true,
209
+ writable: true
210
+ });
211
+ } else {
212
+ obj[key] = value;
213
+ }
214
+ return obj;
215
+ }
216
+ function _type_of$6(obj) {
217
+ "@swc/helpers - typeof";
218
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
219
+ }
220
+ var HttpResponse = /*#__PURE__*/ function() {
221
+ function HttpResponse(options) {
222
+ _class_call_check$4(this, HttpResponse);
223
+ _define_property$4(this, "statusCode", void 0);
224
+ _define_property$4(this, "reason", void 0);
225
+ _define_property$4(this, "headers", void 0);
226
+ _define_property$4(this, "body", void 0);
227
+ this.statusCode = options.statusCode;
228
+ this.reason = options.reason;
229
+ this.headers = options.headers || {};
230
+ this.body = options.body;
231
+ }
232
+ _create_class$3(HttpResponse, null, [
233
+ {
234
+ key: "isInstance",
235
+ value: function isInstance(response) {
236
+ if (!response) return false;
237
+ var resp = response;
238
+ return typeof resp.statusCode === "number" && _type_of$6(resp.headers) === "object";
239
+ }
240
+ }
241
+ ]);
242
+ return HttpResponse;
243
+ }();
244
+
245
+ function buildQueryString(query) {
246
+ var parts = [];
247
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
248
+ try {
249
+ for(var _iterator = Object.keys(query).sort()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
250
+ var key = _step.value;
251
+ var value = query[key];
252
+ key = escapeUri(key);
253
+ if (Array.isArray(value)) {
254
+ for(var i = 0, iLen = value.length; i < iLen; i++){
255
+ parts.push("".concat(key, "=").concat(escapeUri(value[i])));
256
+ }
257
+ } else {
258
+ var qsEntry = key;
259
+ if (value || typeof value === "string") {
260
+ qsEntry += "=".concat(escapeUri(value));
261
+ }
262
+ parts.push(qsEntry);
263
+ }
264
+ }
265
+ } catch (err) {
266
+ _didIteratorError = true;
267
+ _iteratorError = err;
268
+ } finally{
269
+ try {
270
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
271
+ _iterator.return();
272
+ }
273
+ } finally{
274
+ if (_didIteratorError) {
275
+ throw _iteratorError;
276
+ }
277
+ }
278
+ }
279
+ return parts.join("&");
280
+ }
281
+
282
+ var NODEJS_TIMEOUT_ERROR_CODES = [
283
+ "ECONNRESET",
284
+ "EPIPE",
285
+ "ETIMEDOUT"
286
+ ];
287
+
288
+ var getTransformedHeaders = function(headers) {
289
+ var transformedHeaders = {};
290
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
291
+ try {
292
+ for(var _iterator = Object.keys(headers)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
293
+ var name = _step.value;
294
+ var headerValues = headers[name];
295
+ transformedHeaders[name] = Array.isArray(headerValues) ? headerValues.join(",") : headerValues;
296
+ }
297
+ } catch (err) {
298
+ _didIteratorError = true;
299
+ _iteratorError = err;
300
+ } finally{
301
+ try {
302
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
303
+ _iterator.return();
304
+ }
305
+ } finally{
306
+ if (_didIteratorError) {
307
+ throw _iteratorError;
308
+ }
309
+ }
310
+ }
311
+ return transformedHeaders;
312
+ };
313
+
314
+ var timing = {
315
+ setTimeout: function(cb, ms) {
316
+ return setTimeout(cb, ms);
317
+ },
318
+ clearTimeout: function(timeoutId) {
319
+ return clearTimeout(timeoutId);
320
+ }
321
+ };
322
+
323
+ var DEFER_EVENT_LISTENER_TIME$2 = 1000;
324
+ var setConnectionTimeout = function(request, reject) {
325
+ var timeoutInMs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
326
+ if (!timeoutInMs) {
327
+ return -1;
328
+ }
329
+ var registerTimeout = function(offset) {
330
+ var timeoutId = timing.setTimeout(function() {
331
+ request.destroy();
332
+ reject(Object.assign(new Error("@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ".concat(timeoutInMs, " ms.")), {
333
+ name: "TimeoutError"
334
+ }));
335
+ }, timeoutInMs - offset);
336
+ var doWithSocket = function(socket) {
337
+ if (socket === null || socket === void 0 ? void 0 : socket.connecting) {
338
+ socket.on("connect", function() {
339
+ timing.clearTimeout(timeoutId);
340
+ });
341
+ } else {
342
+ timing.clearTimeout(timeoutId);
343
+ }
344
+ };
345
+ if (request.socket) {
346
+ doWithSocket(request.socket);
347
+ } else {
348
+ request.on("socket", doWithSocket);
349
+ }
350
+ };
351
+ if (timeoutInMs < 2000) {
352
+ registerTimeout(0);
353
+ return 0;
354
+ }
355
+ return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME$2), DEFER_EVENT_LISTENER_TIME$2);
356
+ };
357
+
358
+ var setRequestTimeout = function(req, reject) {
359
+ var timeoutInMs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0, throwOnRequestTimeout = arguments.length > 3 ? arguments[3] : void 0, logger = arguments.length > 4 ? arguments[4] : void 0;
360
+ if (timeoutInMs) {
361
+ return timing.setTimeout(function() {
362
+ var msg = "@smithy/node-http-handler - [".concat(throwOnRequestTimeout ? "ERROR" : "WARN", "] a request has exceeded the configured ").concat(timeoutInMs, " ms requestTimeout.");
363
+ if (throwOnRequestTimeout) {
364
+ var error = Object.assign(new Error(msg), {
365
+ name: "TimeoutError",
366
+ code: "ETIMEDOUT"
367
+ });
368
+ req.destroy(error);
369
+ reject(error);
370
+ } else {
371
+ var _logger_warn;
372
+ msg += " Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.";
373
+ logger === null || logger === void 0 ? void 0 : (_logger_warn = logger.warn) === null || _logger_warn === void 0 ? void 0 : _logger_warn.call(logger, msg);
374
+ }
375
+ }, timeoutInMs);
376
+ }
377
+ return -1;
378
+ };
379
+
380
+ var DEFER_EVENT_LISTENER_TIME$1 = 3000;
381
+ var setSocketKeepAlive = function(request, param) {
382
+ var keepAlive = param.keepAlive, keepAliveMsecs = param.keepAliveMsecs, deferTimeMs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : DEFER_EVENT_LISTENER_TIME$1;
383
+ if (keepAlive !== true) {
384
+ return -1;
385
+ }
386
+ var registerListener = function() {
387
+ if (request.socket) {
388
+ request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
389
+ } else {
390
+ request.on("socket", function(socket) {
391
+ socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
392
+ });
393
+ }
394
+ };
395
+ if (deferTimeMs === 0) {
396
+ registerListener();
397
+ return 0;
398
+ }
399
+ return timing.setTimeout(registerListener, deferTimeMs);
400
+ };
401
+
402
+ var DEFER_EVENT_LISTENER_TIME = 3000;
403
+ var setSocketTimeout = function(request, reject) {
404
+ var timeoutInMs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
405
+ var registerTimeout = function(offset) {
406
+ var timeout = timeoutInMs - offset;
407
+ var onTimeout = function() {
408
+ request.destroy();
409
+ reject(Object.assign(new Error("@smithy/node-http-handler - the request socket timed out after ".concat(timeoutInMs, " ms of inactivity (configured by client requestHandler).")), {
410
+ name: "TimeoutError"
411
+ }));
412
+ };
413
+ if (request.socket) {
414
+ request.socket.setTimeout(timeout, onTimeout);
415
+ request.on("close", function() {
416
+ var _request_socket;
417
+ return (_request_socket = request.socket) === null || _request_socket === void 0 ? void 0 : _request_socket.removeListener("timeout", onTimeout);
418
+ });
419
+ } else {
420
+ request.setTimeout(timeout, onTimeout);
421
+ }
422
+ };
423
+ if (0 < timeoutInMs && timeoutInMs < 6000) {
424
+ registerTimeout(0);
425
+ return 0;
426
+ }
427
+ return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
428
+ };
429
+
430
+ function asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, key, arg) {
431
+ try {
432
+ var info = gen[key](arg);
433
+ var value = info.value;
434
+ } catch (error) {
435
+ reject(error);
436
+ return;
437
+ }
438
+ if (info.done) {
439
+ resolve(value);
440
+ } else {
441
+ Promise.resolve(value).then(_next, _throw);
442
+ }
443
+ }
444
+ function _async_to_generator$8(fn) {
445
+ return function() {
446
+ var self = this, args = arguments;
447
+ return new Promise(function(resolve, reject) {
448
+ var gen = fn.apply(self, args);
449
+ function _next(value) {
450
+ asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, "next", value);
451
+ }
452
+ function _throw(err) {
453
+ asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, "throw", err);
454
+ }
455
+ _next(undefined);
456
+ });
457
+ };
458
+ }
459
+ function _instanceof$6(left, right) {
460
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
461
+ return !!right[Symbol.hasInstance](left);
462
+ } else {
463
+ return left instanceof right;
464
+ }
465
+ }
466
+ function _type_of$5(obj) {
467
+ "@swc/helpers - typeof";
468
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
469
+ }
470
+ function _ts_generator$8(thisArg, body) {
471
+ var f, y, t, g, _ = {
472
+ label: 0,
473
+ sent: function() {
474
+ if (t[0] & 1) throw t[1];
475
+ return t[1];
476
+ },
477
+ trys: [],
478
+ ops: []
479
+ };
480
+ return g = {
481
+ next: verb(0),
482
+ "throw": verb(1),
483
+ "return": verb(2)
484
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
485
+ return this;
486
+ }), g;
487
+ function verb(n) {
488
+ return function(v) {
489
+ return step([
490
+ n,
491
+ v
492
+ ]);
493
+ };
494
+ }
495
+ function step(op) {
496
+ if (f) throw new TypeError("Generator is already executing.");
497
+ while(_)try {
498
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
499
+ if (y = 0, t) op = [
500
+ op[0] & 2,
501
+ t.value
502
+ ];
503
+ switch(op[0]){
504
+ case 0:
505
+ case 1:
506
+ t = op;
507
+ break;
508
+ case 4:
509
+ _.label++;
510
+ return {
511
+ value: op[1],
512
+ done: false
513
+ };
514
+ case 5:
515
+ _.label++;
516
+ y = op[1];
517
+ op = [
518
+ 0
519
+ ];
520
+ continue;
521
+ case 7:
522
+ op = _.ops.pop();
523
+ _.trys.pop();
524
+ continue;
525
+ default:
526
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
527
+ _ = 0;
528
+ continue;
529
+ }
530
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
531
+ _.label = op[1];
532
+ break;
533
+ }
534
+ if (op[0] === 6 && _.label < t[1]) {
535
+ _.label = t[1];
536
+ t = op;
537
+ break;
538
+ }
539
+ if (t && _.label < t[2]) {
540
+ _.label = t[2];
541
+ _.ops.push(op);
542
+ break;
543
+ }
544
+ if (t[2]) _.ops.pop();
545
+ _.trys.pop();
546
+ continue;
547
+ }
548
+ op = body.call(thisArg, _);
549
+ } catch (e) {
550
+ op = [
551
+ 6,
552
+ e
553
+ ];
554
+ y = 0;
555
+ } finally{
556
+ f = t = 0;
557
+ }
558
+ if (op[0] & 5) throw op[1];
559
+ return {
560
+ value: op[0] ? op[1] : void 0,
561
+ done: true
562
+ };
563
+ }
564
+ }
565
+ var MIN_WAIT_TIME = 6000;
566
+ function writeRequestBody(httpRequest, request) {
567
+ return _writeRequestBody.apply(this, arguments);
568
+ }
569
+ function _writeRequestBody() {
570
+ _writeRequestBody = _async_to_generator$8(function(httpRequest, request) {
571
+ var maxContinueTimeoutMs, _request_headers, headers, expect, timeoutId, sendBody;
572
+ var _arguments = arguments;
573
+ return _ts_generator$8(this, function(_state) {
574
+ switch(_state.label){
575
+ case 0:
576
+ maxContinueTimeoutMs = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : MIN_WAIT_TIME;
577
+ headers = (_request_headers = request.headers) !== null && _request_headers !== void 0 ? _request_headers : {};
578
+ expect = headers["Expect"] || headers["expect"];
579
+ timeoutId = -1;
580
+ sendBody = true;
581
+ if (!(expect === "100-continue")) return [
582
+ 3,
583
+ 2
584
+ ];
585
+ return [
586
+ 4,
587
+ Promise.race([
588
+ new Promise(function(resolve) {
589
+ timeoutId = Number(timing.setTimeout(function() {
590
+ return resolve(true);
591
+ }, Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
592
+ }),
593
+ new Promise(function(resolve) {
594
+ httpRequest.on("continue", function() {
595
+ timing.clearTimeout(timeoutId);
596
+ resolve(true);
597
+ });
598
+ httpRequest.on("response", function() {
599
+ timing.clearTimeout(timeoutId);
600
+ resolve(false);
601
+ });
602
+ httpRequest.on("error", function() {
603
+ timing.clearTimeout(timeoutId);
604
+ resolve(false);
605
+ });
606
+ })
607
+ ])
608
+ ];
609
+ case 1:
610
+ sendBody = _state.sent();
611
+ _state.label = 2;
612
+ case 2:
613
+ if (sendBody) {
614
+ writeBody(httpRequest, request.body);
615
+ }
616
+ return [
617
+ 2
618
+ ];
619
+ }
620
+ });
621
+ });
622
+ return _writeRequestBody.apply(this, arguments);
623
+ }
624
+ function writeBody(httpRequest, body) {
625
+ if (_instanceof$6(body, Readable)) {
626
+ body.pipe(httpRequest);
627
+ return;
628
+ }
629
+ if (body) {
630
+ if (Buffer.isBuffer(body) || typeof body === "string") {
631
+ httpRequest.end(body);
632
+ return;
633
+ }
634
+ var uint8 = body;
635
+ if ((typeof uint8 === "undefined" ? "undefined" : _type_of$5(uint8)) === "object" && uint8.buffer && typeof uint8.byteOffset === "number" && typeof uint8.byteLength === "number") {
636
+ httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
637
+ return;
638
+ }
639
+ httpRequest.end(Buffer.from(body));
640
+ return;
641
+ }
642
+ httpRequest.end();
643
+ }
644
+
645
+ function asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, key, arg) {
646
+ try {
647
+ var info = gen[key](arg);
648
+ var value = info.value;
649
+ } catch (error) {
650
+ reject(error);
651
+ return;
652
+ }
653
+ if (info.done) {
654
+ resolve(value);
655
+ } else {
656
+ Promise.resolve(value).then(_next, _throw);
657
+ }
658
+ }
659
+ function _async_to_generator$7(fn) {
660
+ return function() {
661
+ var self = this, args = arguments;
662
+ return new Promise(function(resolve, reject) {
663
+ var gen = fn.apply(self, args);
664
+ function _next(value) {
665
+ asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, "next", value);
666
+ }
667
+ function _throw(err) {
668
+ asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, "throw", err);
669
+ }
670
+ _next(undefined);
671
+ });
672
+ };
673
+ }
674
+ function _class_call_check$3(instance, Constructor) {
675
+ if (!(instance instanceof Constructor)) {
676
+ throw new TypeError("Cannot call a class as a function");
677
+ }
678
+ }
679
+ function _defineProperties$2(target, props) {
680
+ for(var i = 0; i < props.length; i++){
681
+ var descriptor = props[i];
682
+ descriptor.enumerable = descriptor.enumerable || false;
683
+ descriptor.configurable = true;
684
+ if ("value" in descriptor) descriptor.writable = true;
685
+ Object.defineProperty(target, descriptor.key, descriptor);
686
+ }
687
+ }
688
+ function _create_class$2(Constructor, protoProps, staticProps) {
689
+ if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
690
+ if (staticProps) _defineProperties$2(Constructor, staticProps);
691
+ return Constructor;
692
+ }
693
+ function _define_property$3(obj, key, value) {
694
+ if (key in obj) {
695
+ Object.defineProperty(obj, key, {
696
+ value: value,
697
+ enumerable: true,
698
+ configurable: true,
699
+ writable: true
700
+ });
701
+ } else {
702
+ obj[key] = value;
703
+ }
704
+ return obj;
705
+ }
706
+ function _instanceof$5(left, right) {
707
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
708
+ return !!right[Symbol.hasInstance](left);
709
+ } else {
710
+ return left instanceof right;
711
+ }
712
+ }
713
+ function _object_spread(target) {
714
+ for(var i = 1; i < arguments.length; i++){
715
+ var source = arguments[i] != null ? arguments[i] : {};
716
+ var ownKeys = Object.keys(source);
717
+ if (typeof Object.getOwnPropertySymbols === "function") {
718
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
719
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
720
+ }));
721
+ }
722
+ ownKeys.forEach(function(key) {
723
+ _define_property$3(target, key, source[key]);
724
+ });
725
+ }
726
+ return target;
727
+ }
728
+ function ownKeys(object, enumerableOnly) {
729
+ var keys = Object.keys(object);
730
+ if (Object.getOwnPropertySymbols) {
731
+ var symbols = Object.getOwnPropertySymbols(object);
732
+ keys.push.apply(keys, symbols);
733
+ }
734
+ return keys;
735
+ }
736
+ function _object_spread_props(target, source) {
737
+ source = source != null ? source : {};
738
+ if (Object.getOwnPropertyDescriptors) {
739
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
740
+ } else {
741
+ ownKeys(Object(source)).forEach(function(key) {
742
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
743
+ });
744
+ }
745
+ return target;
746
+ }
747
+ function _type_of$4(obj) {
748
+ "@swc/helpers - typeof";
749
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
750
+ }
751
+ function _ts_generator$7(thisArg, body) {
752
+ var f, y, t, g, _ = {
753
+ label: 0,
754
+ sent: function() {
755
+ if (t[0] & 1) throw t[1];
756
+ return t[1];
757
+ },
758
+ trys: [],
759
+ ops: []
760
+ };
761
+ return g = {
762
+ next: verb(0),
763
+ "throw": verb(1),
764
+ "return": verb(2)
765
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
766
+ return this;
767
+ }), g;
768
+ function verb(n) {
769
+ return function(v) {
770
+ return step([
771
+ n,
772
+ v
773
+ ]);
774
+ };
775
+ }
776
+ function step(op) {
777
+ if (f) throw new TypeError("Generator is already executing.");
778
+ while(_)try {
779
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
780
+ if (y = 0, t) op = [
781
+ op[0] & 2,
782
+ t.value
783
+ ];
784
+ switch(op[0]){
785
+ case 0:
786
+ case 1:
787
+ t = op;
788
+ break;
789
+ case 4:
790
+ _.label++;
791
+ return {
792
+ value: op[1],
793
+ done: false
794
+ };
795
+ case 5:
796
+ _.label++;
797
+ y = op[1];
798
+ op = [
799
+ 0
800
+ ];
801
+ continue;
802
+ case 7:
803
+ op = _.ops.pop();
804
+ _.trys.pop();
805
+ continue;
806
+ default:
807
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
808
+ _ = 0;
809
+ continue;
810
+ }
811
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
812
+ _.label = op[1];
813
+ break;
814
+ }
815
+ if (op[0] === 6 && _.label < t[1]) {
816
+ _.label = t[1];
817
+ t = op;
818
+ break;
819
+ }
820
+ if (t && _.label < t[2]) {
821
+ _.label = t[2];
822
+ _.ops.push(op);
823
+ break;
824
+ }
825
+ if (t[2]) _.ops.pop();
826
+ _.trys.pop();
827
+ continue;
828
+ }
829
+ op = body.call(thisArg, _);
830
+ } catch (e) {
831
+ op = [
832
+ 6,
833
+ e
834
+ ];
835
+ y = 0;
836
+ } finally{
837
+ f = t = 0;
838
+ }
839
+ if (op[0] & 5) throw op[1];
840
+ return {
841
+ value: op[0] ? op[1] : void 0,
842
+ done: true
843
+ };
844
+ }
845
+ }
846
+ var NodeHttpHandler = /*#__PURE__*/ function() {
847
+ function NodeHttpHandler(options) {
848
+ var _this = this;
849
+ _class_call_check$3(this, NodeHttpHandler);
850
+ _define_property$3(this, "config", void 0);
851
+ _define_property$3(this, "configProvider", void 0);
852
+ _define_property$3(this, "socketWarningTimestamp", 0);
853
+ _define_property$3(this, "metadata", {
854
+ handlerProtocol: "http/1.1"
855
+ });
856
+ this.configProvider = new Promise(function(resolve, reject) {
857
+ if (typeof options === "function") {
858
+ options().then(function(_options) {
859
+ resolve(_this.resolveDefaultConfig(_options));
860
+ }).catch(reject);
861
+ } else {
862
+ resolve(_this.resolveDefaultConfig(options));
863
+ }
864
+ });
865
+ }
866
+ _create_class$2(NodeHttpHandler, [
867
+ {
868
+ key: "resolveDefaultConfig",
869
+ value: function resolveDefaultConfig(options) {
870
+ var _ref = options || {}, requestTimeout = _ref.requestTimeout, connectionTimeout = _ref.connectionTimeout, socketTimeout = _ref.socketTimeout, socketAcquisitionWarningTimeout = _ref.socketAcquisitionWarningTimeout, httpAgent = _ref.httpAgent, httpsAgent = _ref.httpsAgent, throwOnRequestTimeout = _ref.throwOnRequestTimeout;
871
+ var keepAlive = true;
872
+ var maxSockets = 50;
873
+ return {
874
+ connectionTimeout: connectionTimeout,
875
+ requestTimeout: requestTimeout,
876
+ socketTimeout: socketTimeout,
877
+ socketAcquisitionWarningTimeout: socketAcquisitionWarningTimeout,
878
+ throwOnRequestTimeout: throwOnRequestTimeout,
879
+ httpAgent: function() {
880
+ if (_instanceof$5(httpAgent, Agent$1) || typeof (httpAgent === null || httpAgent === void 0 ? void 0 : httpAgent.destroy) === "function") {
881
+ return httpAgent;
882
+ }
883
+ return new Agent$1(_object_spread({
884
+ keepAlive: keepAlive,
885
+ maxSockets: maxSockets
886
+ }, httpAgent));
887
+ }(),
888
+ httpsAgent: function() {
889
+ if (_instanceof$5(httpsAgent, Agent) || typeof (httpsAgent === null || httpsAgent === void 0 ? void 0 : httpsAgent.destroy) === "function") {
890
+ return httpsAgent;
891
+ }
892
+ return new Agent(_object_spread({
893
+ keepAlive: keepAlive,
894
+ maxSockets: maxSockets
895
+ }, httpsAgent));
896
+ }(),
897
+ logger: console
898
+ };
899
+ }
900
+ },
901
+ {
902
+ key: "destroy",
903
+ value: function destroy() {
904
+ var _this_config_httpAgent, _this_config, _this_config_httpsAgent, _this_config1;
905
+ (_this_config = this.config) === null || _this_config === void 0 ? void 0 : (_this_config_httpAgent = _this_config.httpAgent) === null || _this_config_httpAgent === void 0 ? void 0 : _this_config_httpAgent.destroy();
906
+ (_this_config1 = this.config) === null || _this_config1 === void 0 ? void 0 : (_this_config_httpsAgent = _this_config1.httpsAgent) === null || _this_config_httpsAgent === void 0 ? void 0 : _this_config_httpsAgent.destroy();
907
+ }
908
+ },
909
+ {
910
+ key: "handle",
911
+ value: function handle(request$2) {
912
+ var _ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, abortSignal = _ref.abortSignal, requestTimeout = _ref.requestTimeout;
913
+ var _this = this;
914
+ return _async_to_generator$7(function() {
915
+ return _ts_generator$7(this, function(_state) {
916
+ switch(_state.label){
917
+ case 0:
918
+ if (!!_this.config) return [
919
+ 3,
920
+ 2
921
+ ];
922
+ return [
923
+ 4,
924
+ _this.configProvider
925
+ ];
926
+ case 1:
927
+ _this.config = _state.sent();
928
+ _state.label = 2;
929
+ case 2:
930
+ return [
931
+ 2,
932
+ new Promise(function(_resolve, _reject) {
933
+ var writeRequestBodyPromise = undefined;
934
+ var timeouts = [];
935
+ var resolve = function() {
936
+ var _ref = _async_to_generator$7(function(arg) {
937
+ return _ts_generator$7(this, function(_state) {
938
+ switch(_state.label){
939
+ case 0:
940
+ return [
941
+ 4,
942
+ writeRequestBodyPromise
943
+ ];
944
+ case 1:
945
+ _state.sent();
946
+ timeouts.forEach(timing.clearTimeout);
947
+ _resolve(arg);
948
+ return [
949
+ 2
950
+ ];
951
+ }
952
+ });
953
+ });
954
+ return function resolve(arg) {
955
+ return _ref.apply(this, arguments);
956
+ };
957
+ }();
958
+ var reject = function() {
959
+ var _ref = _async_to_generator$7(function(arg) {
960
+ return _ts_generator$7(this, function(_state) {
961
+ switch(_state.label){
962
+ case 0:
963
+ return [
964
+ 4,
965
+ writeRequestBodyPromise
966
+ ];
967
+ case 1:
968
+ _state.sent();
969
+ timeouts.forEach(timing.clearTimeout);
970
+ _reject(arg);
971
+ return [
972
+ 2
973
+ ];
974
+ }
975
+ });
976
+ });
977
+ return function reject(arg) {
978
+ return _ref.apply(this, arguments);
979
+ };
980
+ }();
981
+ if (!_this.config) {
982
+ throw new Error("Node HTTP request handler config is not resolved");
983
+ }
984
+ if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
985
+ var abortError = new Error("Request aborted");
986
+ abortError.name = "AbortError";
987
+ reject(abortError);
988
+ return;
989
+ }
990
+ var isSSL = request$2.protocol === "https:";
991
+ var agent = isSSL ? _this.config.httpsAgent : _this.config.httpAgent;
992
+ var _this_config_requestTimeout, _this_config_connectionTimeout, _this_config_socketAcquisitionWarningTimeout;
993
+ timeouts.push(timing.setTimeout(function() {
994
+ _this.socketWarningTimestamp = NodeHttpHandler.checkSocketUsage(agent, _this.socketWarningTimestamp, _this.config.logger);
995
+ }, (_this_config_socketAcquisitionWarningTimeout = _this.config.socketAcquisitionWarningTimeout) !== null && _this_config_socketAcquisitionWarningTimeout !== void 0 ? _this_config_socketAcquisitionWarningTimeout : ((_this_config_requestTimeout = _this.config.requestTimeout) !== null && _this_config_requestTimeout !== void 0 ? _this_config_requestTimeout : 2000) + ((_this_config_connectionTimeout = _this.config.connectionTimeout) !== null && _this_config_connectionTimeout !== void 0 ? _this_config_connectionTimeout : 1000)));
996
+ var queryString = buildQueryString(request$2.query || {});
997
+ var auth = undefined;
998
+ if (request$2.username != null || request$2.password != null) {
999
+ var _request_username;
1000
+ var username = (_request_username = request$2.username) !== null && _request_username !== void 0 ? _request_username : "";
1001
+ var _request_password;
1002
+ var password = (_request_password = request$2.password) !== null && _request_password !== void 0 ? _request_password : "";
1003
+ auth = "".concat(username, ":").concat(password);
1004
+ }
1005
+ var path = request$2.path;
1006
+ if (queryString) {
1007
+ path += "?".concat(queryString);
1008
+ }
1009
+ if (request$2.fragment) {
1010
+ path += "#".concat(request$2.fragment);
1011
+ }
1012
+ var _request_hostname;
1013
+ var hostname = (_request_hostname = request$2.hostname) !== null && _request_hostname !== void 0 ? _request_hostname : "";
1014
+ if (hostname[0] === "[" && hostname.endsWith("]")) {
1015
+ hostname = request$2.hostname.slice(1, -1);
1016
+ } else {
1017
+ hostname = request$2.hostname;
1018
+ }
1019
+ var nodeHttpsOptions = {
1020
+ headers: request$2.headers,
1021
+ host: hostname,
1022
+ method: request$2.method,
1023
+ path: path,
1024
+ port: request$2.port,
1025
+ agent: agent,
1026
+ auth: auth
1027
+ };
1028
+ var requestFunc = isSSL ? request : request$1;
1029
+ var req = requestFunc(nodeHttpsOptions, function(res) {
1030
+ var httpResponse = new HttpResponse({
1031
+ statusCode: res.statusCode || -1,
1032
+ reason: res.statusMessage,
1033
+ headers: getTransformedHeaders(res.headers),
1034
+ body: res
1035
+ });
1036
+ resolve({
1037
+ response: httpResponse
1038
+ });
1039
+ });
1040
+ req.on("error", function(err) {
1041
+ if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
1042
+ reject(Object.assign(err, {
1043
+ name: "TimeoutError"
1044
+ }));
1045
+ } else {
1046
+ reject(err);
1047
+ }
1048
+ });
1049
+ if (abortSignal) {
1050
+ var onAbort = function() {
1051
+ req.destroy();
1052
+ var abortError = new Error("Request aborted");
1053
+ abortError.name = "AbortError";
1054
+ reject(abortError);
1055
+ };
1056
+ if (typeof abortSignal.addEventListener === "function") {
1057
+ var signal = abortSignal;
1058
+ signal.addEventListener("abort", onAbort, {
1059
+ once: true
1060
+ });
1061
+ req.once("close", function() {
1062
+ return signal.removeEventListener("abort", onAbort);
1063
+ });
1064
+ } else {
1065
+ abortSignal.onabort = onAbort;
1066
+ }
1067
+ }
1068
+ var effectiveRequestTimeout = requestTimeout !== null && requestTimeout !== void 0 ? requestTimeout : _this.config.requestTimeout;
1069
+ timeouts.push(setConnectionTimeout(req, reject, _this.config.connectionTimeout));
1070
+ var _this_config_logger;
1071
+ timeouts.push(setRequestTimeout(req, reject, effectiveRequestTimeout, _this.config.throwOnRequestTimeout, (_this_config_logger = _this.config.logger) !== null && _this_config_logger !== void 0 ? _this_config_logger : console));
1072
+ timeouts.push(setSocketTimeout(req, reject, _this.config.socketTimeout));
1073
+ var httpAgent = nodeHttpsOptions.agent;
1074
+ if ((typeof httpAgent === "undefined" ? "undefined" : _type_of$4(httpAgent)) === "object" && "keepAlive" in httpAgent) {
1075
+ timeouts.push(setSocketKeepAlive(req, {
1076
+ keepAlive: httpAgent.keepAlive,
1077
+ keepAliveMsecs: httpAgent.keepAliveMsecs
1078
+ }));
1079
+ }
1080
+ writeRequestBodyPromise = writeRequestBody(req, request$2, effectiveRequestTimeout).catch(function(e) {
1081
+ timeouts.forEach(timing.clearTimeout);
1082
+ return _reject(e);
1083
+ });
1084
+ })
1085
+ ];
1086
+ }
1087
+ });
1088
+ })();
1089
+ }
1090
+ },
1091
+ {
1092
+ key: "updateHttpClientConfig",
1093
+ value: function updateHttpClientConfig(key, value) {
1094
+ this.config = undefined;
1095
+ this.configProvider = this.configProvider.then(function(config) {
1096
+ return _object_spread_props(_object_spread({}, config), _define_property$3({}, key, value));
1097
+ });
1098
+ }
1099
+ },
1100
+ {
1101
+ key: "httpHandlerConfigs",
1102
+ value: function httpHandlerConfigs() {
1103
+ var _this_config;
1104
+ return (_this_config = this.config) !== null && _this_config !== void 0 ? _this_config : {};
1105
+ }
1106
+ }
1107
+ ], [
1108
+ {
1109
+ key: "create",
1110
+ value: function create(instanceOrOptions) {
1111
+ if (typeof (instanceOrOptions === null || instanceOrOptions === void 0 ? void 0 : instanceOrOptions.handle) === "function") {
1112
+ return instanceOrOptions;
1113
+ }
1114
+ return new NodeHttpHandler(instanceOrOptions);
1115
+ }
1116
+ },
1117
+ {
1118
+ key: "checkSocketUsage",
1119
+ value: function checkSocketUsage(agent, socketWarningTimestamp) {
1120
+ var logger = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : console;
1121
+ var sockets = agent.sockets, requests = agent.requests, maxSockets = agent.maxSockets;
1122
+ if (typeof maxSockets !== "number" || maxSockets === Infinity) {
1123
+ return socketWarningTimestamp;
1124
+ }
1125
+ var interval = 15000;
1126
+ if (Date.now() - interval < socketWarningTimestamp) {
1127
+ return socketWarningTimestamp;
1128
+ }
1129
+ if (sockets && requests) {
1130
+ for(var origin in sockets){
1131
+ var _sockets_origin, _requests_origin;
1132
+ var _sockets_origin_length;
1133
+ var socketsInUse = (_sockets_origin_length = (_sockets_origin = sockets[origin]) === null || _sockets_origin === void 0 ? void 0 : _sockets_origin.length) !== null && _sockets_origin_length !== void 0 ? _sockets_origin_length : 0;
1134
+ var _requests_origin_length;
1135
+ var requestsEnqueued = (_requests_origin_length = (_requests_origin = requests[origin]) === null || _requests_origin === void 0 ? void 0 : _requests_origin.length) !== null && _requests_origin_length !== void 0 ? _requests_origin_length : 0;
1136
+ if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
1137
+ var _logger_warn;
1138
+ logger === null || logger === void 0 ? void 0 : (_logger_warn = logger.warn) === null || _logger_warn === void 0 ? void 0 : _logger_warn.call(logger, "@smithy/node-http-handler:WARN - socket usage at capacity=".concat(socketsInUse, " and ").concat(requestsEnqueued, " additional requests are enqueued.\nSee https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html\nor increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config."));
1139
+ return Date.now();
1140
+ }
1141
+ }
1142
+ }
1143
+ return socketWarningTimestamp;
1144
+ }
1145
+ }
1146
+ ]);
1147
+ return NodeHttpHandler;
1148
+ }();
1149
+
1150
+ function _assert_this_initialized$2(self) {
1151
+ if (self === void 0) {
1152
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1153
+ }
1154
+ return self;
1155
+ }
1156
+ function _class_call_check$2(instance, Constructor) {
1157
+ if (!(instance instanceof Constructor)) {
1158
+ throw new TypeError("Cannot call a class as a function");
1159
+ }
1160
+ }
1161
+ function _defineProperties$1(target, props) {
1162
+ for(var i = 0; i < props.length; i++){
1163
+ var descriptor = props[i];
1164
+ descriptor.enumerable = descriptor.enumerable || false;
1165
+ descriptor.configurable = true;
1166
+ if ("value" in descriptor) descriptor.writable = true;
1167
+ Object.defineProperty(target, descriptor.key, descriptor);
1168
+ }
1169
+ }
1170
+ function _create_class$1(Constructor, protoProps, staticProps) {
1171
+ if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
1172
+ return Constructor;
1173
+ }
1174
+ function _define_property$2(obj, key, value) {
1175
+ if (key in obj) {
1176
+ Object.defineProperty(obj, key, {
1177
+ value: value,
1178
+ enumerable: true,
1179
+ configurable: true,
1180
+ writable: true
1181
+ });
1182
+ } else {
1183
+ obj[key] = value;
1184
+ }
1185
+ return obj;
1186
+ }
1187
+ function _get_prototype_of$2(o) {
1188
+ _get_prototype_of$2 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
1189
+ return o.__proto__ || Object.getPrototypeOf(o);
1190
+ };
1191
+ return _get_prototype_of$2(o);
1192
+ }
1193
+ function _inherits$2(subClass, superClass) {
1194
+ if (typeof superClass !== "function" && superClass !== null) {
1195
+ throw new TypeError("Super expression must either be null or a function");
1196
+ }
1197
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
1198
+ constructor: {
1199
+ value: subClass,
1200
+ writable: true,
1201
+ configurable: true
1202
+ }
1203
+ });
1204
+ if (superClass) _set_prototype_of$2(subClass, superClass);
1205
+ }
1206
+ function _possible_constructor_return$2(self, call) {
1207
+ if (call && (_type_of$3(call) === "object" || typeof call === "function")) {
1208
+ return call;
1209
+ }
1210
+ return _assert_this_initialized$2(self);
1211
+ }
1212
+ function _set_prototype_of$2(o, p) {
1213
+ _set_prototype_of$2 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
1214
+ o.__proto__ = p;
1215
+ return o;
1216
+ };
1217
+ return _set_prototype_of$2(o, p);
1218
+ }
1219
+ function _type_of$3(obj) {
1220
+ "@swc/helpers - typeof";
1221
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1222
+ }
1223
+ function _is_native_reflect_construct$2() {
1224
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
1225
+ if (Reflect.construct.sham) return false;
1226
+ if (typeof Proxy === "function") return true;
1227
+ try {
1228
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
1229
+ return true;
1230
+ } catch (e) {
1231
+ return false;
1232
+ }
1233
+ }
1234
+ function _create_super$2(Derived) {
1235
+ var hasNativeReflectConstruct = _is_native_reflect_construct$2();
1236
+ return function _createSuperInternal() {
1237
+ var Super = _get_prototype_of$2(Derived), result;
1238
+ if (hasNativeReflectConstruct) {
1239
+ var NewTarget = _get_prototype_of$2(this).constructor;
1240
+ result = Reflect.construct(Super, arguments, NewTarget);
1241
+ } else {
1242
+ result = Super.apply(this, arguments);
1243
+ }
1244
+ return _possible_constructor_return$2(this, result);
1245
+ };
1246
+ }
1247
+ var Collector = /*#__PURE__*/ function(Writable) {
1248
+ _inherits$2(Collector, Writable);
1249
+ var _super = _create_super$2(Collector);
1250
+ function Collector() {
1251
+ _class_call_check$2(this, Collector);
1252
+ var _this;
1253
+ _this = _super.apply(this, arguments);
1254
+ _define_property$2(_assert_this_initialized$2(_this), "bufferedBytes", []);
1255
+ return _this;
1256
+ }
1257
+ _create_class$1(Collector, [
1258
+ {
1259
+ key: "_write",
1260
+ value: function _write(chunk, encoding, callback) {
1261
+ this.bufferedBytes.push(chunk);
1262
+ callback();
1263
+ }
1264
+ }
1265
+ ]);
1266
+ return Collector;
1267
+ }(Writable);
1268
+
1269
+ function asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, key, arg) {
1270
+ try {
1271
+ var info = gen[key](arg);
1272
+ var value = info.value;
1273
+ } catch (error) {
1274
+ reject(error);
1275
+ return;
1276
+ }
1277
+ if (info.done) {
1278
+ resolve(value);
1279
+ } else {
1280
+ Promise.resolve(value).then(_next, _throw);
1281
+ }
1282
+ }
1283
+ function _async_to_generator$6(fn) {
1284
+ return function() {
1285
+ var self = this, args = arguments;
1286
+ return new Promise(function(resolve, reject) {
1287
+ var gen = fn.apply(self, args);
1288
+ function _next(value) {
1289
+ asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, "next", value);
1290
+ }
1291
+ function _throw(err) {
1292
+ asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, "throw", err);
1293
+ }
1294
+ _next(undefined);
1295
+ });
1296
+ };
1297
+ }
1298
+ function _instanceof$4(left, right) {
1299
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
1300
+ return !!right[Symbol.hasInstance](left);
1301
+ } else {
1302
+ return left instanceof right;
1303
+ }
1304
+ }
1305
+ function _ts_generator$6(thisArg, body) {
1306
+ var f, y, t, g, _ = {
1307
+ label: 0,
1308
+ sent: function() {
1309
+ if (t[0] & 1) throw t[1];
1310
+ return t[1];
1311
+ },
1312
+ trys: [],
1313
+ ops: []
1314
+ };
1315
+ return g = {
1316
+ next: verb(0),
1317
+ "throw": verb(1),
1318
+ "return": verb(2)
1319
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
1320
+ return this;
1321
+ }), g;
1322
+ function verb(n) {
1323
+ return function(v) {
1324
+ return step([
1325
+ n,
1326
+ v
1327
+ ]);
1328
+ };
1329
+ }
1330
+ function step(op) {
1331
+ if (f) throw new TypeError("Generator is already executing.");
1332
+ while(_)try {
1333
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
1334
+ if (y = 0, t) op = [
1335
+ op[0] & 2,
1336
+ t.value
1337
+ ];
1338
+ switch(op[0]){
1339
+ case 0:
1340
+ case 1:
1341
+ t = op;
1342
+ break;
1343
+ case 4:
1344
+ _.label++;
1345
+ return {
1346
+ value: op[1],
1347
+ done: false
1348
+ };
1349
+ case 5:
1350
+ _.label++;
1351
+ y = op[1];
1352
+ op = [
1353
+ 0
1354
+ ];
1355
+ continue;
1356
+ case 7:
1357
+ op = _.ops.pop();
1358
+ _.trys.pop();
1359
+ continue;
1360
+ default:
1361
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1362
+ _ = 0;
1363
+ continue;
1364
+ }
1365
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1366
+ _.label = op[1];
1367
+ break;
1368
+ }
1369
+ if (op[0] === 6 && _.label < t[1]) {
1370
+ _.label = t[1];
1371
+ t = op;
1372
+ break;
1373
+ }
1374
+ if (t && _.label < t[2]) {
1375
+ _.label = t[2];
1376
+ _.ops.push(op);
1377
+ break;
1378
+ }
1379
+ if (t[2]) _.ops.pop();
1380
+ _.trys.pop();
1381
+ continue;
1382
+ }
1383
+ op = body.call(thisArg, _);
1384
+ } catch (e) {
1385
+ op = [
1386
+ 6,
1387
+ e
1388
+ ];
1389
+ y = 0;
1390
+ } finally{
1391
+ f = t = 0;
1392
+ }
1393
+ if (op[0] & 5) throw op[1];
1394
+ return {
1395
+ value: op[0] ? op[1] : void 0,
1396
+ done: true
1397
+ };
1398
+ }
1399
+ }
1400
+ var streamCollector$1 = function(stream) {
1401
+ if (isReadableStreamInstance(stream)) {
1402
+ return collectReadableStream(stream);
1403
+ }
1404
+ return new Promise(function(resolve, reject) {
1405
+ var collector = new Collector();
1406
+ stream.pipe(collector);
1407
+ stream.on("error", function(err) {
1408
+ collector.end();
1409
+ reject(err);
1410
+ });
1411
+ collector.on("error", reject);
1412
+ collector.on("finish", function() {
1413
+ var bytes = new Uint8Array(Buffer.concat(this.bufferedBytes));
1414
+ resolve(bytes);
1415
+ });
1416
+ });
1417
+ };
1418
+ var isReadableStreamInstance = function(stream) {
1419
+ return typeof ReadableStream === "function" && _instanceof$4(stream, ReadableStream);
1420
+ };
1421
+ function collectReadableStream(stream) {
1422
+ return _collectReadableStream.apply(this, arguments);
1423
+ }
1424
+ function _collectReadableStream() {
1425
+ _collectReadableStream = _async_to_generator$6(function(stream) {
1426
+ var chunks, reader, isDone, length, _ref, done, value, collected, offset, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk;
1427
+ return _ts_generator$6(this, function(_state) {
1428
+ switch(_state.label){
1429
+ case 0:
1430
+ chunks = [];
1431
+ reader = stream.getReader();
1432
+ isDone = false;
1433
+ length = 0;
1434
+ _state.label = 1;
1435
+ case 1:
1436
+ if (!!isDone) return [
1437
+ 3,
1438
+ 3
1439
+ ];
1440
+ return [
1441
+ 4,
1442
+ reader.read()
1443
+ ];
1444
+ case 2:
1445
+ _ref = _state.sent(), done = _ref.done, value = _ref.value;
1446
+ if (value) {
1447
+ chunks.push(value);
1448
+ length += value.length;
1449
+ }
1450
+ isDone = done;
1451
+ return [
1452
+ 3,
1453
+ 1
1454
+ ];
1455
+ case 3:
1456
+ collected = new Uint8Array(length);
1457
+ offset = 0;
1458
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1459
+ try {
1460
+ for(_iterator = chunks[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1461
+ chunk = _step.value;
1462
+ collected.set(chunk, offset);
1463
+ offset += chunk.length;
1464
+ }
1465
+ } catch (err) {
1466
+ _didIteratorError = true;
1467
+ _iteratorError = err;
1468
+ } finally{
1469
+ try {
1470
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1471
+ _iterator.return();
1472
+ }
1473
+ } finally{
1474
+ if (_didIteratorError) {
1475
+ throw _iteratorError;
1476
+ }
1477
+ }
1478
+ }
1479
+ return [
1480
+ 2,
1481
+ collected
1482
+ ];
1483
+ }
1484
+ });
1485
+ });
1486
+ return _collectReadableStream.apply(this, arguments);
1487
+ }
1488
+
1489
+ function _assert_this_initialized$1(self) {
1490
+ if (self === void 0) {
1491
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1492
+ }
1493
+ return self;
1494
+ }
1495
+ function _class_call_check$1(instance, Constructor) {
1496
+ if (!(instance instanceof Constructor)) {
1497
+ throw new TypeError("Cannot call a class as a function");
1498
+ }
1499
+ }
1500
+ function _construct(Parent, args, Class) {
1501
+ if (_is_native_reflect_construct$1()) {
1502
+ _construct = Reflect.construct;
1503
+ } else {
1504
+ _construct = function construct(Parent, args, Class) {
1505
+ var a = [
1506
+ null
1507
+ ];
1508
+ a.push.apply(a, args);
1509
+ var Constructor = Function.bind.apply(Parent, a);
1510
+ var instance = new Constructor();
1511
+ if (Class) _set_prototype_of$1(instance, Class.prototype);
1512
+ return instance;
1513
+ };
1514
+ }
1515
+ return _construct.apply(null, arguments);
1516
+ }
1517
+ function _defineProperties(target, props) {
1518
+ for(var i = 0; i < props.length; i++){
1519
+ var descriptor = props[i];
1520
+ descriptor.enumerable = descriptor.enumerable || false;
1521
+ descriptor.configurable = true;
1522
+ if ("value" in descriptor) descriptor.writable = true;
1523
+ Object.defineProperty(target, descriptor.key, descriptor);
1524
+ }
1525
+ }
1526
+ function _create_class(Constructor, protoProps, staticProps) {
1527
+ if (staticProps) _defineProperties(Constructor, staticProps);
1528
+ return Constructor;
1529
+ }
1530
+ function _define_property$1(obj, key, value) {
1531
+ if (key in obj) {
1532
+ Object.defineProperty(obj, key, {
1533
+ value: value,
1534
+ enumerable: true,
1535
+ configurable: true,
1536
+ writable: true
1537
+ });
1538
+ } else {
1539
+ obj[key] = value;
1540
+ }
1541
+ return obj;
1542
+ }
1543
+ function _get_prototype_of$1(o) {
1544
+ _get_prototype_of$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
1545
+ return o.__proto__ || Object.getPrototypeOf(o);
1546
+ };
1547
+ return _get_prototype_of$1(o);
1548
+ }
1549
+ function _inherits$1(subClass, superClass) {
1550
+ if (typeof superClass !== "function" && superClass !== null) {
1551
+ throw new TypeError("Super expression must either be null or a function");
1552
+ }
1553
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
1554
+ constructor: {
1555
+ value: subClass,
1556
+ writable: true,
1557
+ configurable: true
1558
+ }
1559
+ });
1560
+ if (superClass) _set_prototype_of$1(subClass, superClass);
1561
+ }
1562
+ function _is_native_function(fn) {
1563
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
1564
+ }
1565
+ function _possible_constructor_return$1(self, call) {
1566
+ if (call && (_type_of$2(call) === "object" || typeof call === "function")) {
1567
+ return call;
1568
+ }
1569
+ return _assert_this_initialized$1(self);
1570
+ }
1571
+ function _set_prototype_of$1(o, p) {
1572
+ _set_prototype_of$1 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
1573
+ o.__proto__ = p;
1574
+ return o;
1575
+ };
1576
+ return _set_prototype_of$1(o, p);
1577
+ }
1578
+ function _type_of$2(obj) {
1579
+ "@swc/helpers - typeof";
1580
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1581
+ }
1582
+ function _wrap_native_super(Class) {
1583
+ var _cache = typeof Map === "function" ? new Map() : undefined;
1584
+ _wrap_native_super = function wrapNativeSuper(Class) {
1585
+ if (Class === null || !_is_native_function(Class)) return Class;
1586
+ if (typeof Class !== "function") {
1587
+ throw new TypeError("Super expression must either be null or a function");
1588
+ }
1589
+ if (typeof _cache !== "undefined") {
1590
+ if (_cache.has(Class)) return _cache.get(Class);
1591
+ _cache.set(Class, Wrapper);
1592
+ }
1593
+ function Wrapper() {
1594
+ return _construct(Class, arguments, _get_prototype_of$1(this).constructor);
1595
+ }
1596
+ Wrapper.prototype = Object.create(Class.prototype, {
1597
+ constructor: {
1598
+ value: Wrapper,
1599
+ enumerable: false,
1600
+ writable: true,
1601
+ configurable: true
1602
+ }
1603
+ });
1604
+ return _set_prototype_of$1(Wrapper, Class);
1605
+ };
1606
+ return _wrap_native_super(Class);
1607
+ }
1608
+ function _is_native_reflect_construct$1() {
1609
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
1610
+ if (Reflect.construct.sham) return false;
1611
+ if (typeof Proxy === "function") return true;
1612
+ try {
1613
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
1614
+ return true;
1615
+ } catch (e) {
1616
+ return false;
1617
+ }
1618
+ }
1619
+ function _create_super$1(Derived) {
1620
+ var hasNativeReflectConstruct = _is_native_reflect_construct$1();
1621
+ return function _createSuperInternal() {
1622
+ var Super = _get_prototype_of$1(Derived), result;
1623
+ if (hasNativeReflectConstruct) {
1624
+ var NewTarget = _get_prototype_of$1(this).constructor;
1625
+ result = Reflect.construct(Super, arguments, NewTarget);
1626
+ } else {
1627
+ result = Super.apply(this, arguments);
1628
+ }
1629
+ return _possible_constructor_return$1(this, result);
1630
+ };
1631
+ }
1632
+ var ProviderError = /*#__PURE__*/ function(Error1) {
1633
+ _inherits$1(ProviderError, Error1);
1634
+ var _super = _create_super$1(ProviderError);
1635
+ function ProviderError(message) {
1636
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
1637
+ _class_call_check$1(this, ProviderError);
1638
+ var _this;
1639
+ var _logger_debug;
1640
+ var logger;
1641
+ var tryNextLink = true;
1642
+ if (typeof options === "boolean") {
1643
+ logger = undefined;
1644
+ tryNextLink = options;
1645
+ } else if (options != null && (typeof options === "undefined" ? "undefined" : _type_of$2(options)) === "object") {
1646
+ logger = options.logger;
1647
+ var _options_tryNextLink;
1648
+ tryNextLink = (_options_tryNextLink = options.tryNextLink) !== null && _options_tryNextLink !== void 0 ? _options_tryNextLink : true;
1649
+ }
1650
+ _this = _super.call(this, message);
1651
+ _define_property$1(_assert_this_initialized$1(_this), "name", "ProviderError");
1652
+ _define_property$1(_assert_this_initialized$1(_this), "tryNextLink", void 0);
1653
+ _this.tryNextLink = tryNextLink;
1654
+ Object.setPrototypeOf(_assert_this_initialized$1(_this), ProviderError.prototype);
1655
+ logger === null || logger === void 0 ? void 0 : (_logger_debug = logger.debug) === null || _logger_debug === void 0 ? void 0 : _logger_debug.call(logger, "@smithy/property-provider ".concat(tryNextLink ? "->" : "(!)", " ").concat(message));
1656
+ return _this;
1657
+ }
1658
+ _create_class(ProviderError, null, [
1659
+ {
1660
+ key: "from",
1661
+ value: function from(error) {
1662
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
1663
+ return Object.assign(new this(error.message, options), error);
1664
+ }
1665
+ }
1666
+ ]);
1667
+ return ProviderError;
1668
+ }(_wrap_native_super(Error));
1669
+
1670
+ function _assert_this_initialized(self) {
1671
+ if (self === void 0) {
1672
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1673
+ }
1674
+ return self;
1675
+ }
1676
+ function _class_call_check(instance, Constructor) {
1677
+ if (!(instance instanceof Constructor)) {
1678
+ throw new TypeError("Cannot call a class as a function");
1679
+ }
1680
+ }
1681
+ function _define_property(obj, key, value) {
1682
+ if (key in obj) {
1683
+ Object.defineProperty(obj, key, {
1684
+ value: value,
1685
+ enumerable: true,
1686
+ configurable: true,
1687
+ writable: true
1688
+ });
1689
+ } else {
1690
+ obj[key] = value;
1691
+ }
1692
+ return obj;
1693
+ }
1694
+ function _get_prototype_of(o) {
1695
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
1696
+ return o.__proto__ || Object.getPrototypeOf(o);
1697
+ };
1698
+ return _get_prototype_of(o);
1699
+ }
1700
+ function _inherits(subClass, superClass) {
1701
+ if (typeof superClass !== "function" && superClass !== null) {
1702
+ throw new TypeError("Super expression must either be null or a function");
1703
+ }
1704
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
1705
+ constructor: {
1706
+ value: subClass,
1707
+ writable: true,
1708
+ configurable: true
1709
+ }
1710
+ });
1711
+ if (superClass) _set_prototype_of(subClass, superClass);
1712
+ }
1713
+ function _possible_constructor_return(self, call) {
1714
+ if (call && (_type_of$1(call) === "object" || typeof call === "function")) {
1715
+ return call;
1716
+ }
1717
+ return _assert_this_initialized(self);
1718
+ }
1719
+ function _set_prototype_of(o, p) {
1720
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
1721
+ o.__proto__ = p;
1722
+ return o;
1723
+ };
1724
+ return _set_prototype_of(o, p);
1725
+ }
1726
+ function _type_of$1(obj) {
1727
+ "@swc/helpers - typeof";
1728
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1729
+ }
1730
+ function _is_native_reflect_construct() {
1731
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
1732
+ if (Reflect.construct.sham) return false;
1733
+ if (typeof Proxy === "function") return true;
1734
+ try {
1735
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
1736
+ return true;
1737
+ } catch (e) {
1738
+ return false;
1739
+ }
1740
+ }
1741
+ function _create_super(Derived) {
1742
+ var hasNativeReflectConstruct = _is_native_reflect_construct();
1743
+ return function _createSuperInternal() {
1744
+ var Super = _get_prototype_of(Derived), result;
1745
+ if (hasNativeReflectConstruct) {
1746
+ var NewTarget = _get_prototype_of(this).constructor;
1747
+ result = Reflect.construct(Super, arguments, NewTarget);
1748
+ } else {
1749
+ result = Super.apply(this, arguments);
1750
+ }
1751
+ return _possible_constructor_return(this, result);
1752
+ };
1753
+ }
1754
+ var CredentialsProviderError = /*#__PURE__*/ function(ProviderError) {
1755
+ _inherits(CredentialsProviderError, ProviderError);
1756
+ var _super = _create_super(CredentialsProviderError);
1757
+ function CredentialsProviderError(message) {
1758
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
1759
+ _class_call_check(this, CredentialsProviderError);
1760
+ var _this;
1761
+ _this = _super.call(this, message, options);
1762
+ _define_property(_assert_this_initialized(_this), "name", "CredentialsProviderError");
1763
+ Object.setPrototypeOf(_assert_this_initialized(_this), CredentialsProviderError.prototype);
1764
+ return _this;
1765
+ }
1766
+ return CredentialsProviderError;
1767
+ }(ProviderError);
1768
+
1769
+ var ECS_CONTAINER_HOST = "169.254.170.2";
1770
+ var EKS_CONTAINER_HOST_IPv4 = "169.254.170.23";
1771
+ var EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]";
1772
+ var checkUrl = function(url, logger) {
1773
+ if (url.protocol === "https:") {
1774
+ return;
1775
+ }
1776
+ if (url.hostname === ECS_CONTAINER_HOST || url.hostname === EKS_CONTAINER_HOST_IPv4 || url.hostname === EKS_CONTAINER_HOST_IPv6) {
1777
+ return;
1778
+ }
1779
+ if (url.hostname.includes("[")) {
1780
+ if (url.hostname === "[::1]" || url.hostname === "[0000:0000:0000:0000:0000:0000:0000:0001]") {
1781
+ return;
1782
+ }
1783
+ } else {
1784
+ if (url.hostname === "localhost") {
1785
+ return;
1786
+ }
1787
+ var ipComponents = url.hostname.split(".");
1788
+ var inRange = function(component) {
1789
+ var num = parseInt(component, 10);
1790
+ return 0 <= num && num <= 255;
1791
+ };
1792
+ if (ipComponents[0] === "127" && inRange(ipComponents[1]) && inRange(ipComponents[2]) && inRange(ipComponents[3]) && ipComponents.length === 4) {
1793
+ return;
1794
+ }
1795
+ }
1796
+ throw new CredentialsProviderError("URL not accepted. It must either be HTTPS or match one of the following:\n - loopback CIDR 127.0.0.0/8 or [::1/128]\n - ECS container host 169.254.170.2\n - EKS container host 169.254.170.23 or [fd00:ec2::23]", {
1797
+ logger: logger
1798
+ });
1799
+ };
1800
+
1801
+ function _instanceof$3(left, right) {
1802
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
1803
+ return !!right[Symbol.hasInstance](left);
1804
+ } else {
1805
+ return left instanceof right;
1806
+ }
1807
+ }
1808
+ var isReadableStream = function(stream) {
1809
+ var _stream_constructor;
1810
+ return typeof ReadableStream === "function" && ((stream === null || stream === void 0 ? void 0 : (_stream_constructor = stream.constructor) === null || _stream_constructor === void 0 ? void 0 : _stream_constructor.name) === ReadableStream.name || _instanceof$3(stream, ReadableStream));
1811
+ };
1812
+
1813
+ function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
1814
+ try {
1815
+ var info = gen[key](arg);
1816
+ var value = info.value;
1817
+ } catch (error) {
1818
+ reject(error);
1819
+ return;
1820
+ }
1821
+ if (info.done) {
1822
+ resolve(value);
1823
+ } else {
1824
+ Promise.resolve(value).then(_next, _throw);
1825
+ }
1826
+ }
1827
+ function _async_to_generator$5(fn) {
1828
+ return function() {
1829
+ var self = this, args = arguments;
1830
+ return new Promise(function(resolve, reject) {
1831
+ var gen = fn.apply(self, args);
1832
+ function _next(value) {
1833
+ asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "next", value);
1834
+ }
1835
+ function _throw(err) {
1836
+ asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "throw", err);
1837
+ }
1838
+ _next(undefined);
1839
+ });
1840
+ };
1841
+ }
1842
+ function _instanceof$2(left, right) {
1843
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
1844
+ return !!right[Symbol.hasInstance](left);
1845
+ } else {
1846
+ return left instanceof right;
1847
+ }
1848
+ }
1849
+ function _ts_generator$5(thisArg, body) {
1850
+ var f, y, t, g, _ = {
1851
+ label: 0,
1852
+ sent: function() {
1853
+ if (t[0] & 1) throw t[1];
1854
+ return t[1];
1855
+ },
1856
+ trys: [],
1857
+ ops: []
1858
+ };
1859
+ return g = {
1860
+ next: verb(0),
1861
+ "throw": verb(1),
1862
+ "return": verb(2)
1863
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
1864
+ return this;
1865
+ }), g;
1866
+ function verb(n) {
1867
+ return function(v) {
1868
+ return step([
1869
+ n,
1870
+ v
1871
+ ]);
1872
+ };
1873
+ }
1874
+ function step(op) {
1875
+ if (f) throw new TypeError("Generator is already executing.");
1876
+ while(_)try {
1877
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
1878
+ if (y = 0, t) op = [
1879
+ op[0] & 2,
1880
+ t.value
1881
+ ];
1882
+ switch(op[0]){
1883
+ case 0:
1884
+ case 1:
1885
+ t = op;
1886
+ break;
1887
+ case 4:
1888
+ _.label++;
1889
+ return {
1890
+ value: op[1],
1891
+ done: false
1892
+ };
1893
+ case 5:
1894
+ _.label++;
1895
+ y = op[1];
1896
+ op = [
1897
+ 0
1898
+ ];
1899
+ continue;
1900
+ case 7:
1901
+ op = _.ops.pop();
1902
+ _.trys.pop();
1903
+ continue;
1904
+ default:
1905
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1906
+ _ = 0;
1907
+ continue;
1908
+ }
1909
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1910
+ _.label = op[1];
1911
+ break;
1912
+ }
1913
+ if (op[0] === 6 && _.label < t[1]) {
1914
+ _.label = t[1];
1915
+ t = op;
1916
+ break;
1917
+ }
1918
+ if (t && _.label < t[2]) {
1919
+ _.label = t[2];
1920
+ _.ops.push(op);
1921
+ break;
1922
+ }
1923
+ if (t[2]) _.ops.pop();
1924
+ _.trys.pop();
1925
+ continue;
1926
+ }
1927
+ op = body.call(thisArg, _);
1928
+ } catch (e) {
1929
+ op = [
1930
+ 6,
1931
+ e
1932
+ ];
1933
+ y = 0;
1934
+ } finally{
1935
+ f = t = 0;
1936
+ }
1937
+ if (op[0] & 5) throw op[1];
1938
+ return {
1939
+ value: op[0] ? op[1] : void 0,
1940
+ done: true
1941
+ };
1942
+ }
1943
+ }
1944
+ var streamCollector = function() {
1945
+ var _ref = _async_to_generator$5(function(stream) {
1946
+ var _stream_constructor, _;
1947
+ return _ts_generator$5(this, function(_state) {
1948
+ switch(_state.label){
1949
+ case 0:
1950
+ if (!(typeof Blob === "function" && _instanceof$2(stream, Blob) || ((_stream_constructor = stream.constructor) === null || _stream_constructor === void 0 ? void 0 : _stream_constructor.name) === "Blob")) return [
1951
+ 3,
1952
+ 3
1953
+ ];
1954
+ if (!(Blob.prototype.arrayBuffer !== undefined)) return [
1955
+ 3,
1956
+ 2
1957
+ ];
1958
+ _ = Uint8Array.bind;
1959
+ return [
1960
+ 4,
1961
+ stream.arrayBuffer()
1962
+ ];
1963
+ case 1:
1964
+ return [
1965
+ 2,
1966
+ new (_.apply(Uint8Array, [
1967
+ void 0,
1968
+ _state.sent()
1969
+ ]))
1970
+ ];
1971
+ case 2:
1972
+ return [
1973
+ 2,
1974
+ collectBlob(stream)
1975
+ ];
1976
+ case 3:
1977
+ return [
1978
+ 2,
1979
+ collectStream(stream)
1980
+ ];
1981
+ }
1982
+ });
1983
+ });
1984
+ return function streamCollector(stream) {
1985
+ return _ref.apply(this, arguments);
1986
+ };
1987
+ }();
1988
+ function collectBlob(blob) {
1989
+ return _collectBlob.apply(this, arguments);
1990
+ }
1991
+ function _collectBlob() {
1992
+ _collectBlob = _async_to_generator$5(function(blob) {
1993
+ var base64, arrayBuffer;
1994
+ return _ts_generator$5(this, function(_state) {
1995
+ switch(_state.label){
1996
+ case 0:
1997
+ return [
1998
+ 4,
1999
+ readToBase64(blob)
2000
+ ];
2001
+ case 1:
2002
+ base64 = _state.sent();
2003
+ arrayBuffer = fromBase64(base64);
2004
+ return [
2005
+ 2,
2006
+ new Uint8Array(arrayBuffer)
2007
+ ];
2008
+ }
2009
+ });
2010
+ });
2011
+ return _collectBlob.apply(this, arguments);
2012
+ }
2013
+ function collectStream(stream) {
2014
+ return _collectStream.apply(this, arguments);
2015
+ }
2016
+ function _collectStream() {
2017
+ _collectStream = _async_to_generator$5(function(stream) {
2018
+ var chunks, reader, isDone, length, _ref, done, value, collected, offset, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk;
2019
+ return _ts_generator$5(this, function(_state) {
2020
+ switch(_state.label){
2021
+ case 0:
2022
+ chunks = [];
2023
+ reader = stream.getReader();
2024
+ isDone = false;
2025
+ length = 0;
2026
+ _state.label = 1;
2027
+ case 1:
2028
+ if (!!isDone) return [
2029
+ 3,
2030
+ 3
2031
+ ];
2032
+ return [
2033
+ 4,
2034
+ reader.read()
2035
+ ];
2036
+ case 2:
2037
+ _ref = _state.sent(), done = _ref.done, value = _ref.value;
2038
+ if (value) {
2039
+ chunks.push(value);
2040
+ length += value.length;
2041
+ }
2042
+ isDone = done;
2043
+ return [
2044
+ 3,
2045
+ 1
2046
+ ];
2047
+ case 3:
2048
+ collected = new Uint8Array(length);
2049
+ offset = 0;
2050
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2051
+ try {
2052
+ for(_iterator = chunks[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2053
+ chunk = _step.value;
2054
+ collected.set(chunk, offset);
2055
+ offset += chunk.length;
2056
+ }
2057
+ } catch (err) {
2058
+ _didIteratorError = true;
2059
+ _iteratorError = err;
2060
+ } finally{
2061
+ try {
2062
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2063
+ _iterator.return();
2064
+ }
2065
+ } finally{
2066
+ if (_didIteratorError) {
2067
+ throw _iteratorError;
2068
+ }
2069
+ }
2070
+ }
2071
+ return [
2072
+ 2,
2073
+ collected
2074
+ ];
2075
+ }
2076
+ });
2077
+ });
2078
+ return _collectStream.apply(this, arguments);
2079
+ }
2080
+ function readToBase64(blob) {
2081
+ return new Promise(function(resolve, reject) {
2082
+ var reader = new FileReader();
2083
+ reader.onloadend = function() {
2084
+ if (reader.readyState !== 2) {
2085
+ return reject(new Error("Reader aborted too early"));
2086
+ }
2087
+ var _reader_result;
2088
+ var result = (_reader_result = reader.result) !== null && _reader_result !== void 0 ? _reader_result : "";
2089
+ var commaIndex = result.indexOf(",");
2090
+ var dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length;
2091
+ resolve(result.substring(dataOffset));
2092
+ };
2093
+ reader.onabort = function() {
2094
+ return reject(new Error("Read aborted"));
2095
+ };
2096
+ reader.onerror = function() {
2097
+ return reject(reader.error);
2098
+ };
2099
+ reader.readAsDataURL(blob);
2100
+ });
2101
+ }
2102
+
2103
+ function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
2104
+ try {
2105
+ var info = gen[key](arg);
2106
+ var value = info.value;
2107
+ } catch (error) {
2108
+ reject(error);
2109
+ return;
2110
+ }
2111
+ if (info.done) {
2112
+ resolve(value);
2113
+ } else {
2114
+ Promise.resolve(value).then(_next, _throw);
2115
+ }
2116
+ }
2117
+ function _async_to_generator$4(fn) {
2118
+ return function() {
2119
+ var self = this, args = arguments;
2120
+ return new Promise(function(resolve, reject) {
2121
+ var gen = fn.apply(self, args);
2122
+ function _next(value) {
2123
+ asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
2124
+ }
2125
+ function _throw(err) {
2126
+ asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
2127
+ }
2128
+ _next(undefined);
2129
+ });
2130
+ };
2131
+ }
2132
+ function _instanceof$1(left, right) {
2133
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
2134
+ return !!right[Symbol.hasInstance](left);
2135
+ } else {
2136
+ return left instanceof right;
2137
+ }
2138
+ }
2139
+ function _ts_generator$4(thisArg, body) {
2140
+ var f, y, t, g, _ = {
2141
+ label: 0,
2142
+ sent: function() {
2143
+ if (t[0] & 1) throw t[1];
2144
+ return t[1];
2145
+ },
2146
+ trys: [],
2147
+ ops: []
2148
+ };
2149
+ return g = {
2150
+ next: verb(0),
2151
+ "throw": verb(1),
2152
+ "return": verb(2)
2153
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
2154
+ return this;
2155
+ }), g;
2156
+ function verb(n) {
2157
+ return function(v) {
2158
+ return step([
2159
+ n,
2160
+ v
2161
+ ]);
2162
+ };
2163
+ }
2164
+ function step(op) {
2165
+ if (f) throw new TypeError("Generator is already executing.");
2166
+ while(_)try {
2167
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
2168
+ if (y = 0, t) op = [
2169
+ op[0] & 2,
2170
+ t.value
2171
+ ];
2172
+ switch(op[0]){
2173
+ case 0:
2174
+ case 1:
2175
+ t = op;
2176
+ break;
2177
+ case 4:
2178
+ _.label++;
2179
+ return {
2180
+ value: op[1],
2181
+ done: false
2182
+ };
2183
+ case 5:
2184
+ _.label++;
2185
+ y = op[1];
2186
+ op = [
2187
+ 0
2188
+ ];
2189
+ continue;
2190
+ case 7:
2191
+ op = _.ops.pop();
2192
+ _.trys.pop();
2193
+ continue;
2194
+ default:
2195
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
2196
+ _ = 0;
2197
+ continue;
2198
+ }
2199
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
2200
+ _.label = op[1];
2201
+ break;
2202
+ }
2203
+ if (op[0] === 6 && _.label < t[1]) {
2204
+ _.label = t[1];
2205
+ t = op;
2206
+ break;
2207
+ }
2208
+ if (t && _.label < t[2]) {
2209
+ _.label = t[2];
2210
+ _.ops.push(op);
2211
+ break;
2212
+ }
2213
+ if (t[2]) _.ops.pop();
2214
+ _.trys.pop();
2215
+ continue;
2216
+ }
2217
+ op = body.call(thisArg, _);
2218
+ } catch (e) {
2219
+ op = [
2220
+ 6,
2221
+ e
2222
+ ];
2223
+ y = 0;
2224
+ } finally{
2225
+ f = t = 0;
2226
+ }
2227
+ if (op[0] & 5) throw op[1];
2228
+ return {
2229
+ value: op[0] ? op[1] : void 0,
2230
+ done: true
2231
+ };
2232
+ }
2233
+ }
2234
+ var ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED$1 = "The stream has already been transformed.";
2235
+ var sdkStreamMixin$1 = function(stream) {
2236
+ if (!isBlobInstance(stream) && !isReadableStream(stream)) {
2237
+ var _stream___proto___constructor, _stream___proto__;
2238
+ var name = (stream === null || stream === void 0 ? void 0 : (_stream___proto__ = stream.__proto__) === null || _stream___proto__ === void 0 ? void 0 : (_stream___proto___constructor = _stream___proto__.constructor) === null || _stream___proto___constructor === void 0 ? void 0 : _stream___proto___constructor.name) || stream;
2239
+ throw new Error("Unexpected stream implementation, expect Blob or ReadableStream, got ".concat(name));
2240
+ }
2241
+ var transformed = false;
2242
+ var transformToByteArray = function() {
2243
+ var _ref = _async_to_generator$4(function() {
2244
+ return _ts_generator$4(this, function(_state) {
2245
+ switch(_state.label){
2246
+ case 0:
2247
+ if (transformed) {
2248
+ throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED$1);
2249
+ }
2250
+ transformed = true;
2251
+ return [
2252
+ 4,
2253
+ streamCollector(stream)
2254
+ ];
2255
+ case 1:
2256
+ return [
2257
+ 2,
2258
+ _state.sent()
2259
+ ];
2260
+ }
2261
+ });
2262
+ });
2263
+ return function transformToByteArray() {
2264
+ return _ref.apply(this, arguments);
2265
+ };
2266
+ }();
2267
+ var blobToWebStream = function(blob) {
2268
+ if (typeof blob.stream !== "function") {
2269
+ throw new Error("Cannot transform payload Blob to web stream. Please make sure the Blob.stream() is polyfilled.\n" + "If you are using React Native, this API is not yet supported, see: https://react-native.canny.io/feature-requests/p/fetch-streaming-body");
2270
+ }
2271
+ return blob.stream();
2272
+ };
2273
+ return Object.assign(stream, {
2274
+ transformToByteArray: transformToByteArray,
2275
+ transformToString: function() {
2276
+ var _ref = _async_to_generator$4(function(encoding) {
2277
+ var buf;
2278
+ return _ts_generator$4(this, function(_state) {
2279
+ switch(_state.label){
2280
+ case 0:
2281
+ return [
2282
+ 4,
2283
+ transformToByteArray()
2284
+ ];
2285
+ case 1:
2286
+ buf = _state.sent();
2287
+ if (encoding === "base64") {
2288
+ return [
2289
+ 2,
2290
+ toBase64(buf)
2291
+ ];
2292
+ } else if (encoding === "hex") {
2293
+ return [
2294
+ 2,
2295
+ toHex(buf)
2296
+ ];
2297
+ } else if (encoding === undefined || encoding === "utf8" || encoding === "utf-8") {
2298
+ return [
2299
+ 2,
2300
+ toUtf8(buf)
2301
+ ];
2302
+ } else if (typeof TextDecoder === "function") {
2303
+ return [
2304
+ 2,
2305
+ new TextDecoder(encoding).decode(buf)
2306
+ ];
2307
+ } else {
2308
+ throw new Error("TextDecoder is not available, please make sure polyfill is provided.");
2309
+ }
2310
+ }
2311
+ });
2312
+ });
2313
+ return function(encoding) {
2314
+ return _ref.apply(this, arguments);
2315
+ };
2316
+ }(),
2317
+ transformToWebStream: function() {
2318
+ if (transformed) {
2319
+ throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED$1);
2320
+ }
2321
+ transformed = true;
2322
+ if (isBlobInstance(stream)) {
2323
+ return blobToWebStream(stream);
2324
+ } else if (isReadableStream(stream)) {
2325
+ return stream;
2326
+ } else {
2327
+ throw new Error("Cannot transform payload to web stream, got ".concat(stream));
2328
+ }
2329
+ }
2330
+ });
2331
+ };
2332
+ var isBlobInstance = function(stream) {
2333
+ return typeof Blob === "function" && _instanceof$1(stream, Blob);
2334
+ };
2335
+
2336
+ function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
2337
+ try {
2338
+ var info = gen[key](arg);
2339
+ var value = info.value;
2340
+ } catch (error) {
2341
+ reject(error);
2342
+ return;
2343
+ }
2344
+ if (info.done) {
2345
+ resolve(value);
2346
+ } else {
2347
+ Promise.resolve(value).then(_next, _throw);
2348
+ }
2349
+ }
2350
+ function _async_to_generator$3(fn) {
2351
+ return function() {
2352
+ var self = this, args = arguments;
2353
+ return new Promise(function(resolve, reject) {
2354
+ var gen = fn.apply(self, args);
2355
+ function _next(value) {
2356
+ asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
2357
+ }
2358
+ function _throw(err) {
2359
+ asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
2360
+ }
2361
+ _next(undefined);
2362
+ });
2363
+ };
2364
+ }
2365
+ function _instanceof(left, right) {
2366
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
2367
+ return !!right[Symbol.hasInstance](left);
2368
+ } else {
2369
+ return left instanceof right;
2370
+ }
2371
+ }
2372
+ function _ts_generator$3(thisArg, body) {
2373
+ var f, y, t, g, _ = {
2374
+ label: 0,
2375
+ sent: function() {
2376
+ if (t[0] & 1) throw t[1];
2377
+ return t[1];
2378
+ },
2379
+ trys: [],
2380
+ ops: []
2381
+ };
2382
+ return g = {
2383
+ next: verb(0),
2384
+ "throw": verb(1),
2385
+ "return": verb(2)
2386
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
2387
+ return this;
2388
+ }), g;
2389
+ function verb(n) {
2390
+ return function(v) {
2391
+ return step([
2392
+ n,
2393
+ v
2394
+ ]);
2395
+ };
2396
+ }
2397
+ function step(op) {
2398
+ if (f) throw new TypeError("Generator is already executing.");
2399
+ while(_)try {
2400
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
2401
+ if (y = 0, t) op = [
2402
+ op[0] & 2,
2403
+ t.value
2404
+ ];
2405
+ switch(op[0]){
2406
+ case 0:
2407
+ case 1:
2408
+ t = op;
2409
+ break;
2410
+ case 4:
2411
+ _.label++;
2412
+ return {
2413
+ value: op[1],
2414
+ done: false
2415
+ };
2416
+ case 5:
2417
+ _.label++;
2418
+ y = op[1];
2419
+ op = [
2420
+ 0
2421
+ ];
2422
+ continue;
2423
+ case 7:
2424
+ op = _.ops.pop();
2425
+ _.trys.pop();
2426
+ continue;
2427
+ default:
2428
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
2429
+ _ = 0;
2430
+ continue;
2431
+ }
2432
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
2433
+ _.label = op[1];
2434
+ break;
2435
+ }
2436
+ if (op[0] === 6 && _.label < t[1]) {
2437
+ _.label = t[1];
2438
+ t = op;
2439
+ break;
2440
+ }
2441
+ if (t && _.label < t[2]) {
2442
+ _.label = t[2];
2443
+ _.ops.push(op);
2444
+ break;
2445
+ }
2446
+ if (t[2]) _.ops.pop();
2447
+ _.trys.pop();
2448
+ continue;
2449
+ }
2450
+ op = body.call(thisArg, _);
2451
+ } catch (e) {
2452
+ op = [
2453
+ 6,
2454
+ e
2455
+ ];
2456
+ y = 0;
2457
+ } finally{
2458
+ f = t = 0;
2459
+ }
2460
+ if (op[0] & 5) throw op[1];
2461
+ return {
2462
+ value: op[0] ? op[1] : void 0,
2463
+ done: true
2464
+ };
2465
+ }
2466
+ }
2467
+ var ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED = "The stream has already been transformed.";
2468
+ var sdkStreamMixin = function(stream) {
2469
+ if (!_instanceof(stream, Readable)) {
2470
+ try {
2471
+ return sdkStreamMixin$1(stream);
2472
+ } catch (e) {
2473
+ var _stream___proto___constructor, _stream___proto__;
2474
+ var name = (stream === null || stream === void 0 ? void 0 : (_stream___proto__ = stream.__proto__) === null || _stream___proto__ === void 0 ? void 0 : (_stream___proto___constructor = _stream___proto__.constructor) === null || _stream___proto___constructor === void 0 ? void 0 : _stream___proto___constructor.name) || stream;
2475
+ throw new Error("Unexpected stream implementation, expect Stream.Readable instance, got ".concat(name));
2476
+ }
2477
+ }
2478
+ var transformed = false;
2479
+ var transformToByteArray = function() {
2480
+ var _ref = _async_to_generator$3(function() {
2481
+ return _ts_generator$3(this, function(_state) {
2482
+ switch(_state.label){
2483
+ case 0:
2484
+ if (transformed) {
2485
+ throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED);
2486
+ }
2487
+ transformed = true;
2488
+ return [
2489
+ 4,
2490
+ streamCollector$1(stream)
2491
+ ];
2492
+ case 1:
2493
+ return [
2494
+ 2,
2495
+ _state.sent()
2496
+ ];
2497
+ }
2498
+ });
2499
+ });
2500
+ return function transformToByteArray() {
2501
+ return _ref.apply(this, arguments);
2502
+ };
2503
+ }();
2504
+ return Object.assign(stream, {
2505
+ transformToByteArray: transformToByteArray,
2506
+ transformToString: function() {
2507
+ var _ref = _async_to_generator$3(function(encoding) {
2508
+ var buf, decoder;
2509
+ return _ts_generator$3(this, function(_state) {
2510
+ switch(_state.label){
2511
+ case 0:
2512
+ return [
2513
+ 4,
2514
+ transformToByteArray()
2515
+ ];
2516
+ case 1:
2517
+ buf = _state.sent();
2518
+ if (encoding === undefined || Buffer.isEncoding(encoding)) {
2519
+ return [
2520
+ 2,
2521
+ fromArrayBuffer(buf.buffer, buf.byteOffset, buf.byteLength).toString(encoding)
2522
+ ];
2523
+ } else {
2524
+ decoder = new TextDecoder(encoding);
2525
+ return [
2526
+ 2,
2527
+ decoder.decode(buf)
2528
+ ];
2529
+ }
2530
+ }
2531
+ });
2532
+ });
2533
+ return function(encoding) {
2534
+ return _ref.apply(this, arguments);
2535
+ };
2536
+ }(),
2537
+ transformToWebStream: function() {
2538
+ if (transformed) {
2539
+ throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED);
2540
+ }
2541
+ if (stream.readableFlowing !== null) {
2542
+ throw new Error("The stream has been consumed by other callbacks.");
2543
+ }
2544
+ if (typeof Readable.toWeb !== "function") {
2545
+ throw new Error("Readable.toWeb() is not supported. Please ensure a polyfill is available.");
2546
+ }
2547
+ transformed = true;
2548
+ return Readable.toWeb(stream);
2549
+ }
2550
+ });
2551
+ };
2552
+
2553
+ function _type_of(obj) {
2554
+ "@swc/helpers - typeof";
2555
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
2556
+ }
2557
+ var expectNumber = function(value) {
2558
+ if (value === null || value === undefined) {
2559
+ return undefined;
2560
+ }
2561
+ if (typeof value === "string") {
2562
+ var parsed = parseFloat(value);
2563
+ if (!Number.isNaN(parsed)) {
2564
+ if (String(parsed) !== String(value)) {
2565
+ logger.warn(stackTraceWarning("Expected number but observed string: ".concat(value)));
2566
+ }
2567
+ return parsed;
2568
+ }
2569
+ }
2570
+ if (typeof value === "number") {
2571
+ return value;
2572
+ }
2573
+ throw new TypeError("Expected number, got ".concat(typeof value === "undefined" ? "undefined" : _type_of(value), ": ").concat(value));
2574
+ };
2575
+ var MAX_FLOAT = Math.ceil(Math.pow(2, 127) * (2 - Math.pow(2, -23)));
2576
+ var expectFloat32 = function(value) {
2577
+ var expected = expectNumber(value);
2578
+ if (expected !== undefined && !Number.isNaN(expected) && expected !== Infinity && expected !== -Infinity) {
2579
+ if (Math.abs(expected) > MAX_FLOAT) {
2580
+ throw new TypeError("Expected 32-bit float, got ".concat(value));
2581
+ }
2582
+ }
2583
+ return expected;
2584
+ };
2585
+ var expectLong = function(value) {
2586
+ if (value === null || value === undefined) {
2587
+ return undefined;
2588
+ }
2589
+ if (Number.isInteger(value) && !Number.isNaN(value)) {
2590
+ return value;
2591
+ }
2592
+ throw new TypeError("Expected integer, got ".concat(typeof value === "undefined" ? "undefined" : _type_of(value), ": ").concat(value));
2593
+ };
2594
+ var expectShort = function(value) {
2595
+ return expectSizedInt(value, 16);
2596
+ };
2597
+ var expectByte = function(value) {
2598
+ return expectSizedInt(value, 8);
2599
+ };
2600
+ var expectSizedInt = function(value, size) {
2601
+ var expected = expectLong(value);
2602
+ if (expected !== undefined && castInt(expected, size) !== expected) {
2603
+ throw new TypeError("Expected ".concat(size, "-bit integer, got ").concat(value));
2604
+ }
2605
+ return expected;
2606
+ };
2607
+ var castInt = function(value, size) {
2608
+ switch(size){
2609
+ case 32:
2610
+ return Int32Array.of(value)[0];
2611
+ case 16:
2612
+ return Int16Array.of(value)[0];
2613
+ case 8:
2614
+ return Int8Array.of(value)[0];
2615
+ }
2616
+ };
2617
+ var strictParseFloat32 = function(value) {
2618
+ if (typeof value == "string") {
2619
+ return expectFloat32(parseNumber(value));
2620
+ }
2621
+ return expectFloat32(value);
2622
+ };
2623
+ var NUMBER_REGEX = /(-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)|(-?Infinity)|(NaN)/g;
2624
+ var parseNumber = function(value) {
2625
+ var matches = value.match(NUMBER_REGEX);
2626
+ if (matches === null || matches[0].length !== value.length) {
2627
+ throw new TypeError("Expected real number, got implicit NaN");
2628
+ }
2629
+ return parseFloat(value);
2630
+ };
2631
+ var strictParseShort = function(value) {
2632
+ if (typeof value === "string") {
2633
+ return expectShort(parseNumber(value));
2634
+ }
2635
+ return expectShort(value);
2636
+ };
2637
+ var strictParseByte = function(value) {
2638
+ if (typeof value === "string") {
2639
+ return expectByte(parseNumber(value));
2640
+ }
2641
+ return expectByte(value);
2642
+ };
2643
+ var stackTraceWarning = function(message) {
2644
+ return String(new TypeError(message).stack || message).split("\n").slice(0, 5).filter(function(s) {
2645
+ return !s.includes("stackTraceWarning");
2646
+ }).join("\n");
2647
+ };
2648
+ var logger = {
2649
+ warn: console.warn
2650
+ };
2651
+
2652
+ function _array_like_to_array$1(arr, len) {
2653
+ if (len == null || len > arr.length) len = arr.length;
2654
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
2655
+ return arr2;
2656
+ }
2657
+ function _array_with_holes$1(arr) {
2658
+ if (Array.isArray(arr)) return arr;
2659
+ }
2660
+ function _iterable_to_array_limit$1(arr, i) {
2661
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
2662
+ if (_i == null) return;
2663
+ var _arr = [];
2664
+ var _n = true;
2665
+ var _d = false;
2666
+ var _s, _e;
2667
+ try {
2668
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
2669
+ _arr.push(_s.value);
2670
+ if (i && _arr.length === i) break;
2671
+ }
2672
+ } catch (err) {
2673
+ _d = true;
2674
+ _e = err;
2675
+ } finally{
2676
+ try {
2677
+ if (!_n && _i["return"] != null) _i["return"]();
2678
+ } finally{
2679
+ if (_d) throw _e;
2680
+ }
2681
+ }
2682
+ return _arr;
2683
+ }
2684
+ function _non_iterable_rest$1() {
2685
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2686
+ }
2687
+ function _sliced_to_array$1(arr, i) {
2688
+ return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
2689
+ }
2690
+ function _unsupported_iterable_to_array$1(o, minLen) {
2691
+ if (!o) return;
2692
+ if (typeof o === "string") return _array_like_to_array$1(o, minLen);
2693
+ var n = Object.prototype.toString.call(o).slice(8, -1);
2694
+ if (n === "Object" && o.constructor) n = o.constructor.name;
2695
+ if (n === "Map" || n === "Set") return Array.from(n);
2696
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
2697
+ }
2698
+ var MONTHS = [
2699
+ "Jan",
2700
+ "Feb",
2701
+ "Mar",
2702
+ "Apr",
2703
+ "May",
2704
+ "Jun",
2705
+ "Jul",
2706
+ "Aug",
2707
+ "Sep",
2708
+ "Oct",
2709
+ "Nov",
2710
+ "Dec"
2711
+ ];
2712
+ var RFC3339 = new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?[zZ]$/);
2713
+ var parseRfc3339DateTime = function(value) {
2714
+ if (value === null || value === undefined) {
2715
+ return undefined;
2716
+ }
2717
+ if (typeof value !== "string") {
2718
+ throw new TypeError("RFC-3339 date-times must be expressed as strings");
2719
+ }
2720
+ var match = RFC3339.exec(value);
2721
+ if (!match) {
2722
+ throw new TypeError("Invalid RFC-3339 date-time value");
2723
+ }
2724
+ var _match = _sliced_to_array$1(match, 8); _match[0]; var yearStr = _match[1], monthStr = _match[2], dayStr = _match[3], hours = _match[4], minutes = _match[5], seconds = _match[6], fractionalMilliseconds = _match[7];
2725
+ var year = strictParseShort(stripLeadingZeroes(yearStr));
2726
+ var month = parseDateValue(monthStr, "month", 1, 12);
2727
+ var day = parseDateValue(dayStr, "day", 1, 31);
2728
+ return buildDate(year, month, day, {
2729
+ hours: hours,
2730
+ minutes: minutes,
2731
+ seconds: seconds,
2732
+ fractionalMilliseconds: fractionalMilliseconds
2733
+ });
2734
+ };
2735
+ var buildDate = function(year, month, day, time) {
2736
+ var adjustedMonth = month - 1;
2737
+ validateDayOfMonth(year, adjustedMonth, day);
2738
+ return new Date(Date.UTC(year, adjustedMonth, day, parseDateValue(time.hours, "hour", 0, 23), parseDateValue(time.minutes, "minute", 0, 59), parseDateValue(time.seconds, "seconds", 0, 60), parseMilliseconds(time.fractionalMilliseconds)));
2739
+ };
2740
+ var DAYS_IN_MONTH = [
2741
+ 31,
2742
+ 28,
2743
+ 31,
2744
+ 30,
2745
+ 31,
2746
+ 30,
2747
+ 31,
2748
+ 31,
2749
+ 30,
2750
+ 31,
2751
+ 30,
2752
+ 31
2753
+ ];
2754
+ var validateDayOfMonth = function(year, month, day) {
2755
+ var maxDays = DAYS_IN_MONTH[month];
2756
+ if (month === 1 && isLeapYear(year)) {
2757
+ maxDays = 29;
2758
+ }
2759
+ if (day > maxDays) {
2760
+ throw new TypeError("Invalid day for ".concat(MONTHS[month], " in ").concat(year, ": ").concat(day));
2761
+ }
2762
+ };
2763
+ var isLeapYear = function(year) {
2764
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
2765
+ };
2766
+ var parseDateValue = function(value, type, lower, upper) {
2767
+ var dateVal = strictParseByte(stripLeadingZeroes(value));
2768
+ if (dateVal < lower || dateVal > upper) {
2769
+ throw new TypeError("".concat(type, " must be between ").concat(lower, " and ").concat(upper, ", inclusive"));
2770
+ }
2771
+ return dateVal;
2772
+ };
2773
+ var parseMilliseconds = function(value) {
2774
+ if (value === null || value === undefined) {
2775
+ return 0;
2776
+ }
2777
+ return strictParseFloat32("0." + value) * 1000;
2778
+ };
2779
+ var stripLeadingZeroes = function(value) {
2780
+ var idx = 0;
2781
+ while(idx < value.length - 1 && value.charAt(idx) === "0"){
2782
+ idx++;
2783
+ }
2784
+ if (idx === 0) {
2785
+ return value;
2786
+ }
2787
+ return value.slice(idx);
2788
+ };
2789
+
2790
+ function _array_like_to_array(arr, len) {
2791
+ if (len == null || len > arr.length) len = arr.length;
2792
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
2793
+ return arr2;
2794
+ }
2795
+ function _array_with_holes(arr) {
2796
+ if (Array.isArray(arr)) return arr;
2797
+ }
2798
+ function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
2799
+ try {
2800
+ var info = gen[key](arg);
2801
+ var value = info.value;
2802
+ } catch (error) {
2803
+ reject(error);
2804
+ return;
2805
+ }
2806
+ if (info.done) {
2807
+ resolve(value);
2808
+ } else {
2809
+ Promise.resolve(value).then(_next, _throw);
2810
+ }
2811
+ }
2812
+ function _async_to_generator$2(fn) {
2813
+ return function() {
2814
+ var self = this, args = arguments;
2815
+ return new Promise(function(resolve, reject) {
2816
+ var gen = fn.apply(self, args);
2817
+ function _next(value) {
2818
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
2819
+ }
2820
+ function _throw(err) {
2821
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
2822
+ }
2823
+ _next(undefined);
2824
+ });
2825
+ };
2826
+ }
2827
+ function _iterable_to_array_limit(arr, i) {
2828
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
2829
+ if (_i == null) return;
2830
+ var _arr = [];
2831
+ var _n = true;
2832
+ var _d = false;
2833
+ var _s, _e;
2834
+ try {
2835
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
2836
+ _arr.push(_s.value);
2837
+ if (i && _arr.length === i) break;
2838
+ }
2839
+ } catch (err) {
2840
+ _d = true;
2841
+ _e = err;
2842
+ } finally{
2843
+ try {
2844
+ if (!_n && _i["return"] != null) _i["return"]();
2845
+ } finally{
2846
+ if (_d) throw _e;
2847
+ }
2848
+ }
2849
+ return _arr;
2850
+ }
2851
+ function _non_iterable_rest() {
2852
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2853
+ }
2854
+ function _sliced_to_array(arr, i) {
2855
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
2856
+ }
2857
+ function _unsupported_iterable_to_array(o, minLen) {
2858
+ if (!o) return;
2859
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
2860
+ var n = Object.prototype.toString.call(o).slice(8, -1);
2861
+ if (n === "Object" && o.constructor) n = o.constructor.name;
2862
+ if (n === "Map" || n === "Set") return Array.from(n);
2863
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
2864
+ }
2865
+ function _ts_generator$2(thisArg, body) {
2866
+ var f, y, t, g, _ = {
2867
+ label: 0,
2868
+ sent: function() {
2869
+ if (t[0] & 1) throw t[1];
2870
+ return t[1];
2871
+ },
2872
+ trys: [],
2873
+ ops: []
2874
+ };
2875
+ return g = {
2876
+ next: verb(0),
2877
+ "throw": verb(1),
2878
+ "return": verb(2)
2879
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
2880
+ return this;
2881
+ }), g;
2882
+ function verb(n) {
2883
+ return function(v) {
2884
+ return step([
2885
+ n,
2886
+ v
2887
+ ]);
2888
+ };
2889
+ }
2890
+ function step(op) {
2891
+ if (f) throw new TypeError("Generator is already executing.");
2892
+ while(_)try {
2893
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
2894
+ if (y = 0, t) op = [
2895
+ op[0] & 2,
2896
+ t.value
2897
+ ];
2898
+ switch(op[0]){
2899
+ case 0:
2900
+ case 1:
2901
+ t = op;
2902
+ break;
2903
+ case 4:
2904
+ _.label++;
2905
+ return {
2906
+ value: op[1],
2907
+ done: false
2908
+ };
2909
+ case 5:
2910
+ _.label++;
2911
+ y = op[1];
2912
+ op = [
2913
+ 0
2914
+ ];
2915
+ continue;
2916
+ case 7:
2917
+ op = _.ops.pop();
2918
+ _.trys.pop();
2919
+ continue;
2920
+ default:
2921
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
2922
+ _ = 0;
2923
+ continue;
2924
+ }
2925
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
2926
+ _.label = op[1];
2927
+ break;
2928
+ }
2929
+ if (op[0] === 6 && _.label < t[1]) {
2930
+ _.label = t[1];
2931
+ t = op;
2932
+ break;
2933
+ }
2934
+ if (t && _.label < t[2]) {
2935
+ _.label = t[2];
2936
+ _.ops.push(op);
2937
+ break;
2938
+ }
2939
+ if (t[2]) _.ops.pop();
2940
+ _.trys.pop();
2941
+ continue;
2942
+ }
2943
+ op = body.call(thisArg, _);
2944
+ } catch (e) {
2945
+ op = [
2946
+ 6,
2947
+ e
2948
+ ];
2949
+ y = 0;
2950
+ } finally{
2951
+ f = t = 0;
2952
+ }
2953
+ if (op[0] & 5) throw op[1];
2954
+ return {
2955
+ value: op[0] ? op[1] : void 0,
2956
+ done: true
2957
+ };
2958
+ }
2959
+ }
2960
+ function createGetRequest(url) {
2961
+ return new HttpRequest({
2962
+ protocol: url.protocol,
2963
+ hostname: url.hostname,
2964
+ port: Number(url.port),
2965
+ path: url.pathname,
2966
+ query: Array.from(url.searchParams.entries()).reduce(function(acc, param) {
2967
+ var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
2968
+ acc[k] = v;
2969
+ return acc;
2970
+ }, {}),
2971
+ fragment: url.hash
2972
+ });
2973
+ }
2974
+ function getCredentials(response, logger) {
2975
+ return _getCredentials.apply(this, arguments);
2976
+ }
2977
+ function _getCredentials() {
2978
+ _getCredentials = _async_to_generator$2(function(response, logger) {
2979
+ var stream, str, parsed, parsedBody;
2980
+ return _ts_generator$2(this, function(_state) {
2981
+ switch(_state.label){
2982
+ case 0:
2983
+ stream = sdkStreamMixin(response.body);
2984
+ return [
2985
+ 4,
2986
+ stream.transformToString()
2987
+ ];
2988
+ case 1:
2989
+ str = _state.sent();
2990
+ if (response.statusCode === 200) {
2991
+ parsed = JSON.parse(str);
2992
+ if (typeof parsed.AccessKeyId !== "string" || typeof parsed.SecretAccessKey !== "string" || typeof parsed.Token !== "string" || typeof parsed.Expiration !== "string") {
2993
+ throw new CredentialsProviderError("HTTP credential provider response not of the required format, an object matching: " + "{ AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", {
2994
+ logger: logger
2995
+ });
2996
+ }
2997
+ return [
2998
+ 2,
2999
+ {
3000
+ accessKeyId: parsed.AccessKeyId,
3001
+ secretAccessKey: parsed.SecretAccessKey,
3002
+ sessionToken: parsed.Token,
3003
+ expiration: parseRfc3339DateTime(parsed.Expiration)
3004
+ }
3005
+ ];
3006
+ }
3007
+ if (response.statusCode >= 400 && response.statusCode < 500) {
3008
+ parsedBody = {};
3009
+ try {
3010
+ parsedBody = JSON.parse(str);
3011
+ } catch (e) {}
3012
+ throw Object.assign(new CredentialsProviderError("Server responded with status: ".concat(response.statusCode), {
3013
+ logger: logger
3014
+ }), {
3015
+ Code: parsedBody.Code,
3016
+ Message: parsedBody.Message
3017
+ });
3018
+ }
3019
+ throw new CredentialsProviderError("Server responded with status: ".concat(response.statusCode), {
3020
+ logger: logger
3021
+ });
3022
+ }
3023
+ });
3024
+ });
3025
+ return _getCredentials.apply(this, arguments);
3026
+ }
3027
+
3028
+ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
3029
+ try {
3030
+ var info = gen[key](arg);
3031
+ var value = info.value;
3032
+ } catch (error) {
3033
+ reject(error);
3034
+ return;
3035
+ }
3036
+ if (info.done) {
3037
+ resolve(value);
3038
+ } else {
3039
+ Promise.resolve(value).then(_next, _throw);
3040
+ }
3041
+ }
3042
+ function _async_to_generator$1(fn) {
3043
+ return function() {
3044
+ var self = this, args = arguments;
3045
+ return new Promise(function(resolve, reject) {
3046
+ var gen = fn.apply(self, args);
3047
+ function _next(value) {
3048
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
3049
+ }
3050
+ function _throw(err) {
3051
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
3052
+ }
3053
+ _next(undefined);
3054
+ });
3055
+ };
3056
+ }
3057
+ function _ts_generator$1(thisArg, body) {
3058
+ var f, y, t, g, _ = {
3059
+ label: 0,
3060
+ sent: function() {
3061
+ if (t[0] & 1) throw t[1];
3062
+ return t[1];
3063
+ },
3064
+ trys: [],
3065
+ ops: []
3066
+ };
3067
+ return g = {
3068
+ next: verb(0),
3069
+ "throw": verb(1),
3070
+ "return": verb(2)
3071
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
3072
+ return this;
3073
+ }), g;
3074
+ function verb(n) {
3075
+ return function(v) {
3076
+ return step([
3077
+ n,
3078
+ v
3079
+ ]);
3080
+ };
3081
+ }
3082
+ function step(op) {
3083
+ if (f) throw new TypeError("Generator is already executing.");
3084
+ while(_)try {
3085
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
3086
+ if (y = 0, t) op = [
3087
+ op[0] & 2,
3088
+ t.value
3089
+ ];
3090
+ switch(op[0]){
3091
+ case 0:
3092
+ case 1:
3093
+ t = op;
3094
+ break;
3095
+ case 4:
3096
+ _.label++;
3097
+ return {
3098
+ value: op[1],
3099
+ done: false
3100
+ };
3101
+ case 5:
3102
+ _.label++;
3103
+ y = op[1];
3104
+ op = [
3105
+ 0
3106
+ ];
3107
+ continue;
3108
+ case 7:
3109
+ op = _.ops.pop();
3110
+ _.trys.pop();
3111
+ continue;
3112
+ default:
3113
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
3114
+ _ = 0;
3115
+ continue;
3116
+ }
3117
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
3118
+ _.label = op[1];
3119
+ break;
3120
+ }
3121
+ if (op[0] === 6 && _.label < t[1]) {
3122
+ _.label = t[1];
3123
+ t = op;
3124
+ break;
3125
+ }
3126
+ if (t && _.label < t[2]) {
3127
+ _.label = t[2];
3128
+ _.ops.push(op);
3129
+ break;
3130
+ }
3131
+ if (t[2]) _.ops.pop();
3132
+ _.trys.pop();
3133
+ continue;
3134
+ }
3135
+ op = body.call(thisArg, _);
3136
+ } catch (e) {
3137
+ op = [
3138
+ 6,
3139
+ e
3140
+ ];
3141
+ y = 0;
3142
+ } finally{
3143
+ f = t = 0;
3144
+ }
3145
+ if (op[0] & 5) throw op[1];
3146
+ return {
3147
+ value: op[0] ? op[1] : void 0,
3148
+ done: true
3149
+ };
3150
+ }
3151
+ }
3152
+ var retryWrapper = function(toRetry, maxRetries, delayMs) {
3153
+ return /*#__PURE__*/ _async_to_generator$1(function() {
3154
+ var i;
3155
+ return _ts_generator$1(this, function(_state) {
3156
+ switch(_state.label){
3157
+ case 0:
3158
+ i = 0;
3159
+ _state.label = 1;
3160
+ case 1:
3161
+ if (!(i < maxRetries)) return [
3162
+ 3,
3163
+ 7
3164
+ ];
3165
+ _state.label = 2;
3166
+ case 2:
3167
+ _state.trys.push([
3168
+ 2,
3169
+ 4,
3170
+ ,
3171
+ 6
3172
+ ]);
3173
+ return [
3174
+ 4,
3175
+ toRetry()
3176
+ ];
3177
+ case 3:
3178
+ return [
3179
+ 2,
3180
+ _state.sent()
3181
+ ];
3182
+ case 4:
3183
+ _state.sent();
3184
+ return [
3185
+ 4,
3186
+ new Promise(function(resolve) {
3187
+ return setTimeout(resolve, delayMs);
3188
+ })
3189
+ ];
3190
+ case 5:
3191
+ _state.sent();
3192
+ return [
3193
+ 3,
3194
+ 6
3195
+ ];
3196
+ case 6:
3197
+ ++i;
3198
+ return [
3199
+ 3,
3200
+ 1
3201
+ ];
3202
+ case 7:
3203
+ return [
3204
+ 4,
3205
+ toRetry()
3206
+ ];
3207
+ case 8:
3208
+ return [
3209
+ 2,
3210
+ _state.sent()
3211
+ ];
3212
+ }
3213
+ });
3214
+ });
3215
+ };
3216
+
3217
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
3218
+ try {
3219
+ var info = gen[key](arg);
3220
+ var value = info.value;
3221
+ } catch (error) {
3222
+ reject(error);
3223
+ return;
3224
+ }
3225
+ if (info.done) {
3226
+ resolve(value);
3227
+ } else {
3228
+ Promise.resolve(value).then(_next, _throw);
3229
+ }
3230
+ }
3231
+ function _async_to_generator(fn) {
3232
+ return function() {
3233
+ var self = this, args = arguments;
3234
+ return new Promise(function(resolve, reject) {
3235
+ var gen = fn.apply(self, args);
3236
+ function _next(value) {
3237
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
3238
+ }
3239
+ function _throw(err) {
3240
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
3241
+ }
3242
+ _next(undefined);
3243
+ });
3244
+ };
3245
+ }
3246
+ function _ts_generator(thisArg, body) {
3247
+ var f, y, t, g, _ = {
3248
+ label: 0,
3249
+ sent: function() {
3250
+ if (t[0] & 1) throw t[1];
3251
+ return t[1];
3252
+ },
3253
+ trys: [],
3254
+ ops: []
3255
+ };
3256
+ return g = {
3257
+ next: verb(0),
3258
+ "throw": verb(1),
3259
+ "return": verb(2)
3260
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
3261
+ return this;
3262
+ }), g;
3263
+ function verb(n) {
3264
+ return function(v) {
3265
+ return step([
3266
+ n,
3267
+ v
3268
+ ]);
3269
+ };
3270
+ }
3271
+ function step(op) {
3272
+ if (f) throw new TypeError("Generator is already executing.");
3273
+ while(_)try {
3274
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
3275
+ if (y = 0, t) op = [
3276
+ op[0] & 2,
3277
+ t.value
3278
+ ];
3279
+ switch(op[0]){
3280
+ case 0:
3281
+ case 1:
3282
+ t = op;
3283
+ break;
3284
+ case 4:
3285
+ _.label++;
3286
+ return {
3287
+ value: op[1],
3288
+ done: false
3289
+ };
3290
+ case 5:
3291
+ _.label++;
3292
+ y = op[1];
3293
+ op = [
3294
+ 0
3295
+ ];
3296
+ continue;
3297
+ case 7:
3298
+ op = _.ops.pop();
3299
+ _.trys.pop();
3300
+ continue;
3301
+ default:
3302
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
3303
+ _ = 0;
3304
+ continue;
3305
+ }
3306
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
3307
+ _.label = op[1];
3308
+ break;
3309
+ }
3310
+ if (op[0] === 6 && _.label < t[1]) {
3311
+ _.label = t[1];
3312
+ t = op;
3313
+ break;
3314
+ }
3315
+ if (t && _.label < t[2]) {
3316
+ _.label = t[2];
3317
+ _.ops.push(op);
3318
+ break;
3319
+ }
3320
+ if (t[2]) _.ops.pop();
3321
+ _.trys.pop();
3322
+ continue;
3323
+ }
3324
+ op = body.call(thisArg, _);
3325
+ } catch (e) {
3326
+ op = [
3327
+ 6,
3328
+ e
3329
+ ];
3330
+ y = 0;
3331
+ } finally{
3332
+ f = t = 0;
3333
+ }
3334
+ if (op[0] & 5) throw op[1];
3335
+ return {
3336
+ value: op[0] ? op[1] : void 0,
3337
+ done: true
3338
+ };
3339
+ }
3340
+ }
3341
+ var AWS_CONTAINER_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
3342
+ var DEFAULT_LINK_LOCAL_HOST = "http://169.254.170.2";
3343
+ var AWS_CONTAINER_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
3344
+ var AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE = "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE";
3345
+ var AWS_CONTAINER_AUTHORIZATION_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
3346
+ var fromHttp = function() {
3347
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3348
+ var _options_logger, _options_logger_constructor, _options_logger1, _options_logger2;
3349
+ (_options_logger = options.logger) === null || _options_logger === void 0 ? void 0 : _options_logger.debug("@aws-sdk/credential-provider-http - fromHttp");
3350
+ var host;
3351
+ var _options_awsContainerCredentialsRelativeUri;
3352
+ var relative = (_options_awsContainerCredentialsRelativeUri = options.awsContainerCredentialsRelativeUri) !== null && _options_awsContainerCredentialsRelativeUri !== void 0 ? _options_awsContainerCredentialsRelativeUri : process.env[AWS_CONTAINER_CREDENTIALS_RELATIVE_URI];
3353
+ var _options_awsContainerCredentialsFullUri;
3354
+ var full = (_options_awsContainerCredentialsFullUri = options.awsContainerCredentialsFullUri) !== null && _options_awsContainerCredentialsFullUri !== void 0 ? _options_awsContainerCredentialsFullUri : process.env[AWS_CONTAINER_CREDENTIALS_FULL_URI];
3355
+ var _options_awsContainerAuthorizationToken;
3356
+ var token = (_options_awsContainerAuthorizationToken = options.awsContainerAuthorizationToken) !== null && _options_awsContainerAuthorizationToken !== void 0 ? _options_awsContainerAuthorizationToken : process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN];
3357
+ var _options_awsContainerAuthorizationTokenFile;
3358
+ var tokenFile = (_options_awsContainerAuthorizationTokenFile = options.awsContainerAuthorizationTokenFile) !== null && _options_awsContainerAuthorizationTokenFile !== void 0 ? _options_awsContainerAuthorizationTokenFile : process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE];
3359
+ var warn = ((_options_logger1 = options.logger) === null || _options_logger1 === void 0 ? void 0 : (_options_logger_constructor = _options_logger1.constructor) === null || _options_logger_constructor === void 0 ? void 0 : _options_logger_constructor.name) === "NoOpLogger" || !((_options_logger2 = options.logger) === null || _options_logger2 === void 0 ? void 0 : _options_logger2.warn) ? console.warn : options.logger.warn.bind(options.logger);
3360
+ if (relative && full) {
3361
+ warn("@aws-sdk/credential-provider-http: " + "you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri.");
3362
+ warn("awsContainerCredentialsFullUri will take precedence.");
3363
+ }
3364
+ if (token && tokenFile) {
3365
+ warn("@aws-sdk/credential-provider-http: " + "you have set both awsContainerAuthorizationToken and awsContainerAuthorizationTokenFile.");
3366
+ warn("awsContainerAuthorizationToken will take precedence.");
3367
+ }
3368
+ if (full) {
3369
+ host = full;
3370
+ } else if (relative) {
3371
+ host = "".concat(DEFAULT_LINK_LOCAL_HOST).concat(relative);
3372
+ } else {
3373
+ throw new CredentialsProviderError("No HTTP credential provider host provided.\nSet AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.", {
3374
+ logger: options.logger
3375
+ });
3376
+ }
3377
+ var url = new URL(host);
3378
+ checkUrl(url, options.logger);
3379
+ var _options_timeout, _options_timeout1;
3380
+ var requestHandler = NodeHttpHandler.create({
3381
+ requestTimeout: (_options_timeout = options.timeout) !== null && _options_timeout !== void 0 ? _options_timeout : 1000,
3382
+ connectionTimeout: (_options_timeout1 = options.timeout) !== null && _options_timeout1 !== void 0 ? _options_timeout1 : 1000
3383
+ });
3384
+ var _options_maxRetries, _options_timeout2;
3385
+ return retryWrapper(/*#__PURE__*/ _async_to_generator(function() {
3386
+ var request, _, result, e;
3387
+ return _ts_generator(this, function(_state) {
3388
+ switch(_state.label){
3389
+ case 0:
3390
+ request = createGetRequest(url);
3391
+ if (!token) return [
3392
+ 3,
3393
+ 1
3394
+ ];
3395
+ request.headers.Authorization = token;
3396
+ return [
3397
+ 3,
3398
+ 3
3399
+ ];
3400
+ case 1:
3401
+ if (!tokenFile) return [
3402
+ 3,
3403
+ 3
3404
+ ];
3405
+ _ = request.headers;
3406
+ return [
3407
+ 4,
3408
+ fs.readFile(tokenFile)
3409
+ ];
3410
+ case 2:
3411
+ _.Authorization = _state.sent().toString();
3412
+ _state.label = 3;
3413
+ case 3:
3414
+ _state.trys.push([
3415
+ 3,
3416
+ 5,
3417
+ ,
3418
+ 6
3419
+ ]);
3420
+ return [
3421
+ 4,
3422
+ requestHandler.handle(request)
3423
+ ];
3424
+ case 4:
3425
+ result = _state.sent();
3426
+ return [
3427
+ 2,
3428
+ getCredentials(result.response).then(function(creds) {
3429
+ return setCredentialFeature(creds, "CREDENTIALS_HTTP", "z");
3430
+ })
3431
+ ];
3432
+ case 5:
3433
+ e = _state.sent();
3434
+ throw new CredentialsProviderError(String(e), {
3435
+ logger: options.logger
3436
+ });
3437
+ case 6:
3438
+ return [
3439
+ 2
3440
+ ];
3441
+ }
3442
+ });
3443
+ }), (_options_maxRetries = options.maxRetries) !== null && _options_maxRetries !== void 0 ? _options_maxRetries : 3, (_options_timeout2 = options.timeout) !== null && _options_timeout2 !== void 0 ? _options_timeout2 : 1000);
3444
+ };
3445
+
3446
+ export { fromHttp };