@stacksjs/actions 0.70.9 → 0.70.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/core.js +1 -1
- package/dist/build.js +18 -3
- package/dist/chunk-1hqs8kt1.js +179252 -0
- package/dist/{chunk-fxan91t8.js → chunk-2dvnt46s.js} +31 -31
- package/dist/chunk-38cnnp2b.js +3823 -0
- package/dist/chunk-3d7m14ee.js +212 -0
- package/dist/chunk-76zhb40c.js +92 -0
- package/dist/chunk-7s5qcjkt.js +105 -0
- package/dist/{chunk-v1qz355d.js → chunk-8fdqje2t.js} +4 -4
- package/dist/chunk-9exgwfkw.js +1283 -0
- package/dist/chunk-a13x0e43.js +1180 -0
- package/dist/chunk-a7k3cdby.js +2266 -0
- package/dist/chunk-b5g5w1hh.js +1482 -0
- package/dist/chunk-bf8bq8pc.js +205 -0
- package/dist/chunk-bst5srwz.js +662 -0
- package/dist/{chunk-6jdq6549.js → chunk-djkz87qs.js} +18 -3
- package/dist/chunk-f6a9g4qa.js +902 -0
- package/dist/chunk-frw3va9v.js +69 -0
- package/dist/chunk-hsak03yh.js +311 -0
- package/dist/{chunk-8swsxabt.js → chunk-k2wcwm7g.js} +63 -3
- package/dist/chunk-mdj7x1vs.js +790 -0
- package/dist/chunk-mdqphqep.js +438 -0
- package/dist/chunk-p0c688mg.js +729 -0
- package/dist/chunk-pjjzff0p.js +2116 -0
- package/dist/chunk-q81mf99q.js +169 -0
- package/dist/chunk-q9dmga3k.js +11 -0
- package/dist/chunk-qhh0v93n.js +73 -0
- package/dist/chunk-qkm8e752.js +51 -0
- package/dist/chunk-saqpg5nd.js +118 -0
- package/dist/chunk-t5em30ak.js +379 -0
- package/dist/chunk-veja9rez.js +5764 -0
- package/dist/chunk-zsm2c35w.js +72 -0
- package/dist/chunk-zzerxbrm.js +107 -0
- package/dist/database/seed.js +18 -3
- package/dist/deploy/index.js +1 -1
- package/dist/examples.js +1 -1
- package/dist/fresh.js +1 -1
- package/dist/generate/index.js +19 -4
- package/dist/helpers/component-meta.js +10 -10
- package/dist/helpers/lib-entries.js +1 -1
- package/dist/index.js +18 -3
- package/dist/key-generate.js +1 -1
- package/dist/lint/fix.js +1 -1
- package/dist/make.js +1 -1
- package/dist/prepublish.js +1 -1
- package/dist/release.js +18 -3
- package/dist/test/feature.js +1 -1
- package/dist/test/index.js +1 -1
- package/dist/test/unit.js +1 -1
- package/dist/types.js +1 -1
- package/dist/upgrade/index.js +1 -1
- package/dist/upgrade.js +2 -2
- package/package.json +17 -17
- package/dist/chunk-8tjc3whz.js +0 -77989
|
@@ -0,0 +1,2266 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_dist_cjs
|
|
3
|
+
} from "./chunk-saqpg5nd.js";
|
|
4
|
+
import {
|
|
5
|
+
__commonJS,
|
|
6
|
+
__require
|
|
7
|
+
} from "./chunk-9v6qtbez.js";
|
|
8
|
+
|
|
9
|
+
// ../../../../node_modules/@smithy/protocol-http/dist-cjs/index.js
|
|
10
|
+
var require_dist_cjs2 = __commonJS((exports, module) => {
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
15
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var src_exports = {};
|
|
30
|
+
__export(src_exports, {
|
|
31
|
+
Field: () => Field,
|
|
32
|
+
Fields: () => Fields,
|
|
33
|
+
HttpRequest: () => HttpRequest,
|
|
34
|
+
HttpResponse: () => HttpResponse,
|
|
35
|
+
IHttpRequest: () => import_types.HttpRequest,
|
|
36
|
+
getHttpHandlerExtensionConfiguration: () => getHttpHandlerExtensionConfiguration,
|
|
37
|
+
isValidHostname: () => isValidHostname,
|
|
38
|
+
resolveHttpHandlerRuntimeConfig: () => resolveHttpHandlerRuntimeConfig
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(src_exports);
|
|
41
|
+
var getHttpHandlerExtensionConfiguration = /* @__PURE__ */ __name((runtimeConfig) => {
|
|
42
|
+
return {
|
|
43
|
+
setHttpHandler(handler) {
|
|
44
|
+
runtimeConfig.httpHandler = handler;
|
|
45
|
+
},
|
|
46
|
+
httpHandler() {
|
|
47
|
+
return runtimeConfig.httpHandler;
|
|
48
|
+
},
|
|
49
|
+
updateHttpClientConfig(key, value) {
|
|
50
|
+
runtimeConfig.httpHandler?.updateHttpClientConfig(key, value);
|
|
51
|
+
},
|
|
52
|
+
httpHandlerConfigs() {
|
|
53
|
+
return runtimeConfig.httpHandler.httpHandlerConfigs();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}, "getHttpHandlerExtensionConfiguration");
|
|
57
|
+
var resolveHttpHandlerRuntimeConfig = /* @__PURE__ */ __name((httpHandlerExtensionConfiguration) => {
|
|
58
|
+
return {
|
|
59
|
+
httpHandler: httpHandlerExtensionConfiguration.httpHandler()
|
|
60
|
+
};
|
|
61
|
+
}, "resolveHttpHandlerRuntimeConfig");
|
|
62
|
+
var import_types = require_dist_cjs();
|
|
63
|
+
var Field = class {
|
|
64
|
+
static {
|
|
65
|
+
__name(this, "Field");
|
|
66
|
+
}
|
|
67
|
+
constructor({ name, kind = import_types.FieldPosition.HEADER, values = [] }) {
|
|
68
|
+
this.name = name;
|
|
69
|
+
this.kind = kind;
|
|
70
|
+
this.values = values;
|
|
71
|
+
}
|
|
72
|
+
add(value) {
|
|
73
|
+
this.values.push(value);
|
|
74
|
+
}
|
|
75
|
+
set(values) {
|
|
76
|
+
this.values = values;
|
|
77
|
+
}
|
|
78
|
+
remove(value) {
|
|
79
|
+
this.values = this.values.filter((v) => v !== value);
|
|
80
|
+
}
|
|
81
|
+
toString() {
|
|
82
|
+
return this.values.map((v) => v.includes(",") || v.includes(" ") ? `"${v}"` : v).join(", ");
|
|
83
|
+
}
|
|
84
|
+
get() {
|
|
85
|
+
return this.values;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var Fields = class {
|
|
89
|
+
constructor({ fields = [], encoding = "utf-8" }) {
|
|
90
|
+
this.entries = {};
|
|
91
|
+
fields.forEach(this.setField.bind(this));
|
|
92
|
+
this.encoding = encoding;
|
|
93
|
+
}
|
|
94
|
+
static {
|
|
95
|
+
__name(this, "Fields");
|
|
96
|
+
}
|
|
97
|
+
setField(field) {
|
|
98
|
+
this.entries[field.name.toLowerCase()] = field;
|
|
99
|
+
}
|
|
100
|
+
getField(name) {
|
|
101
|
+
return this.entries[name.toLowerCase()];
|
|
102
|
+
}
|
|
103
|
+
removeField(name) {
|
|
104
|
+
delete this.entries[name.toLowerCase()];
|
|
105
|
+
}
|
|
106
|
+
getByType(kind) {
|
|
107
|
+
return Object.values(this.entries).filter((field) => field.kind === kind);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var HttpRequest = class _HttpRequest {
|
|
111
|
+
static {
|
|
112
|
+
__name(this, "HttpRequest");
|
|
113
|
+
}
|
|
114
|
+
constructor(options) {
|
|
115
|
+
this.method = options.method || "GET";
|
|
116
|
+
this.hostname = options.hostname || "localhost";
|
|
117
|
+
this.port = options.port;
|
|
118
|
+
this.query = options.query || {};
|
|
119
|
+
this.headers = options.headers || {};
|
|
120
|
+
this.body = options.body;
|
|
121
|
+
this.protocol = options.protocol ? options.protocol.slice(-1) !== ":" ? `${options.protocol}:` : options.protocol : "https:";
|
|
122
|
+
this.path = options.path ? options.path.charAt(0) !== "/" ? `/${options.path}` : options.path : "/";
|
|
123
|
+
this.username = options.username;
|
|
124
|
+
this.password = options.password;
|
|
125
|
+
this.fragment = options.fragment;
|
|
126
|
+
}
|
|
127
|
+
static clone(request) {
|
|
128
|
+
const cloned = new _HttpRequest({
|
|
129
|
+
...request,
|
|
130
|
+
headers: { ...request.headers }
|
|
131
|
+
});
|
|
132
|
+
if (cloned.query) {
|
|
133
|
+
cloned.query = cloneQuery(cloned.query);
|
|
134
|
+
}
|
|
135
|
+
return cloned;
|
|
136
|
+
}
|
|
137
|
+
static isInstance(request) {
|
|
138
|
+
if (!request) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
const req = request;
|
|
142
|
+
return "method" in req && "protocol" in req && "hostname" in req && "path" in req && typeof req["query"] === "object" && typeof req["headers"] === "object";
|
|
143
|
+
}
|
|
144
|
+
clone() {
|
|
145
|
+
return _HttpRequest.clone(this);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
function cloneQuery(query) {
|
|
149
|
+
return Object.keys(query).reduce((carry, paramName) => {
|
|
150
|
+
const param = query[paramName];
|
|
151
|
+
return {
|
|
152
|
+
...carry,
|
|
153
|
+
[paramName]: Array.isArray(param) ? [...param] : param
|
|
154
|
+
};
|
|
155
|
+
}, {});
|
|
156
|
+
}
|
|
157
|
+
__name(cloneQuery, "cloneQuery");
|
|
158
|
+
var HttpResponse = class {
|
|
159
|
+
static {
|
|
160
|
+
__name(this, "HttpResponse");
|
|
161
|
+
}
|
|
162
|
+
constructor(options) {
|
|
163
|
+
this.statusCode = options.statusCode;
|
|
164
|
+
this.reason = options.reason;
|
|
165
|
+
this.headers = options.headers || {};
|
|
166
|
+
this.body = options.body;
|
|
167
|
+
}
|
|
168
|
+
static isInstance(response) {
|
|
169
|
+
if (!response)
|
|
170
|
+
return false;
|
|
171
|
+
const resp = response;
|
|
172
|
+
return typeof resp.statusCode === "number" && typeof resp.headers === "object";
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
function isValidHostname(hostname) {
|
|
176
|
+
const hostPattern = /^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/;
|
|
177
|
+
return hostPattern.test(hostname);
|
|
178
|
+
}
|
|
179
|
+
__name(isValidHostname, "isValidHostname");
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// ../../../../node_modules/@smithy/util-uri-escape/dist-cjs/index.js
|
|
183
|
+
var require_dist_cjs3 = __commonJS((exports, module) => {
|
|
184
|
+
var __defProp = Object.defineProperty;
|
|
185
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
186
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
187
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
188
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
189
|
+
var __export = (target, all) => {
|
|
190
|
+
for (var name in all)
|
|
191
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
192
|
+
};
|
|
193
|
+
var __copyProps = (to, from, except, desc) => {
|
|
194
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
195
|
+
for (let key of __getOwnPropNames(from))
|
|
196
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
197
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
198
|
+
}
|
|
199
|
+
return to;
|
|
200
|
+
};
|
|
201
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
202
|
+
var src_exports = {};
|
|
203
|
+
__export(src_exports, {
|
|
204
|
+
escapeUri: () => escapeUri,
|
|
205
|
+
escapeUriPath: () => escapeUriPath
|
|
206
|
+
});
|
|
207
|
+
module.exports = __toCommonJS(src_exports);
|
|
208
|
+
var escapeUri = /* @__PURE__ */ __name((uri) => encodeURIComponent(uri).replace(/[!'()*]/g, hexEncode), "escapeUri");
|
|
209
|
+
var hexEncode = /* @__PURE__ */ __name((c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`, "hexEncode");
|
|
210
|
+
var escapeUriPath = /* @__PURE__ */ __name((uri) => uri.split("/").map(escapeUri).join("/"), "escapeUriPath");
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// ../../../../node_modules/@smithy/querystring-builder/dist-cjs/index.js
|
|
214
|
+
var require_dist_cjs4 = __commonJS((exports, module) => {
|
|
215
|
+
var __defProp = Object.defineProperty;
|
|
216
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
217
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
218
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
219
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
220
|
+
var __export = (target, all) => {
|
|
221
|
+
for (var name in all)
|
|
222
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
223
|
+
};
|
|
224
|
+
var __copyProps = (to, from, except, desc) => {
|
|
225
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
226
|
+
for (let key of __getOwnPropNames(from))
|
|
227
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
228
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
229
|
+
}
|
|
230
|
+
return to;
|
|
231
|
+
};
|
|
232
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
233
|
+
var src_exports = {};
|
|
234
|
+
__export(src_exports, {
|
|
235
|
+
buildQueryString: () => buildQueryString
|
|
236
|
+
});
|
|
237
|
+
module.exports = __toCommonJS(src_exports);
|
|
238
|
+
var import_util_uri_escape = require_dist_cjs3();
|
|
239
|
+
function buildQueryString(query) {
|
|
240
|
+
const parts = [];
|
|
241
|
+
for (let key of Object.keys(query).sort()) {
|
|
242
|
+
const value = query[key];
|
|
243
|
+
key = (0, import_util_uri_escape.escapeUri)(key);
|
|
244
|
+
if (Array.isArray(value)) {
|
|
245
|
+
for (let i = 0, iLen = value.length;i < iLen; i++) {
|
|
246
|
+
parts.push(`${key}=${(0, import_util_uri_escape.escapeUri)(value[i])}`);
|
|
247
|
+
}
|
|
248
|
+
} else {
|
|
249
|
+
let qsEntry = key;
|
|
250
|
+
if (value || typeof value === "string") {
|
|
251
|
+
qsEntry += `=${(0, import_util_uri_escape.escapeUri)(value)}`;
|
|
252
|
+
}
|
|
253
|
+
parts.push(qsEntry);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return parts.join("&");
|
|
257
|
+
}
|
|
258
|
+
__name(buildQueryString, "buildQueryString");
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// ../../../../node_modules/@smithy/node-http-handler/dist-cjs/index.js
|
|
262
|
+
var require_dist_cjs5 = __commonJS((exports, module) => {
|
|
263
|
+
var __create = Object.create;
|
|
264
|
+
var __defProp = Object.defineProperty;
|
|
265
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
266
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
267
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
268
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
269
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
270
|
+
var __export = (target, all) => {
|
|
271
|
+
for (var name in all)
|
|
272
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
273
|
+
};
|
|
274
|
+
var __copyProps = (to, from, except, desc) => {
|
|
275
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
276
|
+
for (let key of __getOwnPropNames(from))
|
|
277
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
278
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
279
|
+
}
|
|
280
|
+
return to;
|
|
281
|
+
};
|
|
282
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
283
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
284
|
+
var src_exports = {};
|
|
285
|
+
__export(src_exports, {
|
|
286
|
+
DEFAULT_REQUEST_TIMEOUT: () => DEFAULT_REQUEST_TIMEOUT,
|
|
287
|
+
NodeHttp2Handler: () => NodeHttp2Handler,
|
|
288
|
+
NodeHttpHandler: () => NodeHttpHandler,
|
|
289
|
+
streamCollector: () => streamCollector
|
|
290
|
+
});
|
|
291
|
+
module.exports = __toCommonJS(src_exports);
|
|
292
|
+
var import_protocol_http = require_dist_cjs2();
|
|
293
|
+
var import_querystring_builder = require_dist_cjs4();
|
|
294
|
+
var import_http = __require("node:http");
|
|
295
|
+
var import_https = __require("node:https");
|
|
296
|
+
var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
|
|
297
|
+
var getTransformedHeaders = /* @__PURE__ */ __name((headers) => {
|
|
298
|
+
const transformedHeaders = {};
|
|
299
|
+
for (const name of Object.keys(headers)) {
|
|
300
|
+
const headerValues = headers[name];
|
|
301
|
+
transformedHeaders[name] = Array.isArray(headerValues) ? headerValues.join(",") : headerValues;
|
|
302
|
+
}
|
|
303
|
+
return transformedHeaders;
|
|
304
|
+
}, "getTransformedHeaders");
|
|
305
|
+
var timing = {
|
|
306
|
+
setTimeout: (cb, ms) => setTimeout(cb, ms),
|
|
307
|
+
clearTimeout: (timeoutId) => clearTimeout(timeoutId)
|
|
308
|
+
};
|
|
309
|
+
var DEFER_EVENT_LISTENER_TIME = 1000;
|
|
310
|
+
var setConnectionTimeout = /* @__PURE__ */ __name((request, reject, timeoutInMs = 0) => {
|
|
311
|
+
if (!timeoutInMs) {
|
|
312
|
+
return -1;
|
|
313
|
+
}
|
|
314
|
+
const registerTimeout = /* @__PURE__ */ __name((offset) => {
|
|
315
|
+
const timeoutId = timing.setTimeout(() => {
|
|
316
|
+
request.destroy();
|
|
317
|
+
reject(Object.assign(new Error(`Socket timed out without establishing a connection within ${timeoutInMs} ms`), {
|
|
318
|
+
name: "TimeoutError"
|
|
319
|
+
}));
|
|
320
|
+
}, timeoutInMs - offset);
|
|
321
|
+
const doWithSocket = /* @__PURE__ */ __name((socket) => {
|
|
322
|
+
if (socket?.connecting) {
|
|
323
|
+
socket.on("connect", () => {
|
|
324
|
+
timing.clearTimeout(timeoutId);
|
|
325
|
+
});
|
|
326
|
+
} else {
|
|
327
|
+
timing.clearTimeout(timeoutId);
|
|
328
|
+
}
|
|
329
|
+
}, "doWithSocket");
|
|
330
|
+
if (request.socket) {
|
|
331
|
+
doWithSocket(request.socket);
|
|
332
|
+
} else {
|
|
333
|
+
request.on("socket", doWithSocket);
|
|
334
|
+
}
|
|
335
|
+
}, "registerTimeout");
|
|
336
|
+
if (timeoutInMs < 2000) {
|
|
337
|
+
registerTimeout(0);
|
|
338
|
+
return 0;
|
|
339
|
+
}
|
|
340
|
+
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
|
|
341
|
+
}, "setConnectionTimeout");
|
|
342
|
+
var DEFER_EVENT_LISTENER_TIME2 = 3000;
|
|
343
|
+
var setSocketKeepAlive = /* @__PURE__ */ __name((request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME2) => {
|
|
344
|
+
if (keepAlive !== true) {
|
|
345
|
+
return -1;
|
|
346
|
+
}
|
|
347
|
+
const registerListener = /* @__PURE__ */ __name(() => {
|
|
348
|
+
if (request.socket) {
|
|
349
|
+
request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
350
|
+
} else {
|
|
351
|
+
request.on("socket", (socket) => {
|
|
352
|
+
socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}, "registerListener");
|
|
356
|
+
if (deferTimeMs === 0) {
|
|
357
|
+
registerListener();
|
|
358
|
+
return 0;
|
|
359
|
+
}
|
|
360
|
+
return timing.setTimeout(registerListener, deferTimeMs);
|
|
361
|
+
}, "setSocketKeepAlive");
|
|
362
|
+
var DEFER_EVENT_LISTENER_TIME3 = 3000;
|
|
363
|
+
var setSocketTimeout = /* @__PURE__ */ __name((request, reject, timeoutInMs = DEFAULT_REQUEST_TIMEOUT) => {
|
|
364
|
+
const registerTimeout = /* @__PURE__ */ __name((offset) => {
|
|
365
|
+
const timeout = timeoutInMs - offset;
|
|
366
|
+
const onTimeout = /* @__PURE__ */ __name(() => {
|
|
367
|
+
request.destroy();
|
|
368
|
+
reject(Object.assign(new Error(`Connection timed out after ${timeoutInMs} ms`), { name: "TimeoutError" }));
|
|
369
|
+
}, "onTimeout");
|
|
370
|
+
if (request.socket) {
|
|
371
|
+
request.socket.setTimeout(timeout, onTimeout);
|
|
372
|
+
request.on("close", () => request.socket?.removeListener("timeout", onTimeout));
|
|
373
|
+
} else {
|
|
374
|
+
request.setTimeout(timeout, onTimeout);
|
|
375
|
+
}
|
|
376
|
+
}, "registerTimeout");
|
|
377
|
+
if (0 < timeoutInMs && timeoutInMs < 6000) {
|
|
378
|
+
registerTimeout(0);
|
|
379
|
+
return 0;
|
|
380
|
+
}
|
|
381
|
+
return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME3), DEFER_EVENT_LISTENER_TIME3);
|
|
382
|
+
}, "setSocketTimeout");
|
|
383
|
+
var import_stream = __require("node:stream");
|
|
384
|
+
var MIN_WAIT_TIME = 6000;
|
|
385
|
+
async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME) {
|
|
386
|
+
const headers = request.headers ?? {};
|
|
387
|
+
const expect = headers["Expect"] || headers["expect"];
|
|
388
|
+
let timeoutId = -1;
|
|
389
|
+
let sendBody = true;
|
|
390
|
+
if (expect === "100-continue") {
|
|
391
|
+
sendBody = await Promise.race([
|
|
392
|
+
new Promise((resolve) => {
|
|
393
|
+
timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
394
|
+
}),
|
|
395
|
+
new Promise((resolve) => {
|
|
396
|
+
httpRequest.on("continue", () => {
|
|
397
|
+
timing.clearTimeout(timeoutId);
|
|
398
|
+
resolve(true);
|
|
399
|
+
});
|
|
400
|
+
httpRequest.on("response", () => {
|
|
401
|
+
timing.clearTimeout(timeoutId);
|
|
402
|
+
resolve(false);
|
|
403
|
+
});
|
|
404
|
+
httpRequest.on("error", () => {
|
|
405
|
+
timing.clearTimeout(timeoutId);
|
|
406
|
+
resolve(false);
|
|
407
|
+
});
|
|
408
|
+
})
|
|
409
|
+
]);
|
|
410
|
+
}
|
|
411
|
+
if (sendBody) {
|
|
412
|
+
writeBody(httpRequest, request.body);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
__name(writeRequestBody, "writeRequestBody");
|
|
416
|
+
function writeBody(httpRequest, body) {
|
|
417
|
+
if (body instanceof import_stream.Readable) {
|
|
418
|
+
body.pipe(httpRequest);
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
if (body) {
|
|
422
|
+
if (Buffer.isBuffer(body) || typeof body === "string") {
|
|
423
|
+
httpRequest.end(body);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
const uint8 = body;
|
|
427
|
+
if (typeof uint8 === "object" && uint8.buffer && typeof uint8.byteOffset === "number" && typeof uint8.byteLength === "number") {
|
|
428
|
+
httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
httpRequest.end(Buffer.from(body));
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
httpRequest.end();
|
|
435
|
+
}
|
|
436
|
+
__name(writeBody, "writeBody");
|
|
437
|
+
var DEFAULT_REQUEST_TIMEOUT = 0;
|
|
438
|
+
var NodeHttpHandler = class _NodeHttpHandler {
|
|
439
|
+
constructor(options) {
|
|
440
|
+
this.socketWarningTimestamp = 0;
|
|
441
|
+
this.metadata = { handlerProtocol: "http/1.1" };
|
|
442
|
+
this.configProvider = new Promise((resolve, reject) => {
|
|
443
|
+
if (typeof options === "function") {
|
|
444
|
+
options().then((_options) => {
|
|
445
|
+
resolve(this.resolveDefaultConfig(_options));
|
|
446
|
+
}).catch(reject);
|
|
447
|
+
} else {
|
|
448
|
+
resolve(this.resolveDefaultConfig(options));
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
static {
|
|
453
|
+
__name(this, "NodeHttpHandler");
|
|
454
|
+
}
|
|
455
|
+
static create(instanceOrOptions) {
|
|
456
|
+
if (typeof instanceOrOptions?.handle === "function") {
|
|
457
|
+
return instanceOrOptions;
|
|
458
|
+
}
|
|
459
|
+
return new _NodeHttpHandler(instanceOrOptions);
|
|
460
|
+
}
|
|
461
|
+
static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
|
|
462
|
+
const { sockets, requests, maxSockets } = agent;
|
|
463
|
+
if (typeof maxSockets !== "number" || maxSockets === Infinity) {
|
|
464
|
+
return socketWarningTimestamp;
|
|
465
|
+
}
|
|
466
|
+
const interval = 15000;
|
|
467
|
+
if (Date.now() - interval < socketWarningTimestamp) {
|
|
468
|
+
return socketWarningTimestamp;
|
|
469
|
+
}
|
|
470
|
+
if (sockets && requests) {
|
|
471
|
+
for (const origin in sockets) {
|
|
472
|
+
const socketsInUse = sockets[origin]?.length ?? 0;
|
|
473
|
+
const requestsEnqueued = requests[origin]?.length ?? 0;
|
|
474
|
+
if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
|
|
475
|
+
logger?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
|
|
476
|
+
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
|
|
477
|
+
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
|
|
478
|
+
return Date.now();
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return socketWarningTimestamp;
|
|
483
|
+
}
|
|
484
|
+
resolveDefaultConfig(options) {
|
|
485
|
+
const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent } = options || {};
|
|
486
|
+
const keepAlive = true;
|
|
487
|
+
const maxSockets = 50;
|
|
488
|
+
return {
|
|
489
|
+
connectionTimeout,
|
|
490
|
+
requestTimeout: requestTimeout ?? socketTimeout,
|
|
491
|
+
socketAcquisitionWarningTimeout,
|
|
492
|
+
httpAgent: (() => {
|
|
493
|
+
if (httpAgent instanceof import_http.Agent || typeof httpAgent?.destroy === "function") {
|
|
494
|
+
return httpAgent;
|
|
495
|
+
}
|
|
496
|
+
return new import_http.Agent({ keepAlive, maxSockets, ...httpAgent });
|
|
497
|
+
})(),
|
|
498
|
+
httpsAgent: (() => {
|
|
499
|
+
if (httpsAgent instanceof import_https.Agent || typeof httpsAgent?.destroy === "function") {
|
|
500
|
+
return httpsAgent;
|
|
501
|
+
}
|
|
502
|
+
return new import_https.Agent({ keepAlive, maxSockets, ...httpsAgent });
|
|
503
|
+
})(),
|
|
504
|
+
logger: console
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
destroy() {
|
|
508
|
+
this.config?.httpAgent?.destroy();
|
|
509
|
+
this.config?.httpsAgent?.destroy();
|
|
510
|
+
}
|
|
511
|
+
async handle(request, { abortSignal } = {}) {
|
|
512
|
+
if (!this.config) {
|
|
513
|
+
this.config = await this.configProvider;
|
|
514
|
+
}
|
|
515
|
+
return new Promise((_resolve, _reject) => {
|
|
516
|
+
let writeRequestBodyPromise = undefined;
|
|
517
|
+
const timeouts = [];
|
|
518
|
+
const resolve = /* @__PURE__ */ __name(async (arg) => {
|
|
519
|
+
await writeRequestBodyPromise;
|
|
520
|
+
timeouts.forEach(timing.clearTimeout);
|
|
521
|
+
_resolve(arg);
|
|
522
|
+
}, "resolve");
|
|
523
|
+
const reject = /* @__PURE__ */ __name(async (arg) => {
|
|
524
|
+
await writeRequestBodyPromise;
|
|
525
|
+
timeouts.forEach(timing.clearTimeout);
|
|
526
|
+
_reject(arg);
|
|
527
|
+
}, "reject");
|
|
528
|
+
if (!this.config) {
|
|
529
|
+
throw new Error("Node HTTP request handler config is not resolved");
|
|
530
|
+
}
|
|
531
|
+
if (abortSignal?.aborted) {
|
|
532
|
+
const abortError = new Error("Request aborted");
|
|
533
|
+
abortError.name = "AbortError";
|
|
534
|
+
reject(abortError);
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
const isSSL = request.protocol === "https:";
|
|
538
|
+
const agent = isSSL ? this.config.httpsAgent : this.config.httpAgent;
|
|
539
|
+
timeouts.push(timing.setTimeout(() => {
|
|
540
|
+
this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, this.config.logger);
|
|
541
|
+
}, this.config.socketAcquisitionWarningTimeout ?? (this.config.requestTimeout ?? 2000) + (this.config.connectionTimeout ?? 1000)));
|
|
542
|
+
const queryString = (0, import_querystring_builder.buildQueryString)(request.query || {});
|
|
543
|
+
let auth = undefined;
|
|
544
|
+
if (request.username != null || request.password != null) {
|
|
545
|
+
const username = request.username ?? "";
|
|
546
|
+
const password = request.password ?? "";
|
|
547
|
+
auth = `${username}:${password}`;
|
|
548
|
+
}
|
|
549
|
+
let path = request.path;
|
|
550
|
+
if (queryString) {
|
|
551
|
+
path += `?${queryString}`;
|
|
552
|
+
}
|
|
553
|
+
if (request.fragment) {
|
|
554
|
+
path += `#${request.fragment}`;
|
|
555
|
+
}
|
|
556
|
+
let hostname = request.hostname ?? "";
|
|
557
|
+
if (hostname[0] === "[" && hostname.endsWith("]")) {
|
|
558
|
+
hostname = request.hostname.slice(1, -1);
|
|
559
|
+
} else {
|
|
560
|
+
hostname = request.hostname;
|
|
561
|
+
}
|
|
562
|
+
const nodeHttpsOptions = {
|
|
563
|
+
headers: request.headers,
|
|
564
|
+
host: hostname,
|
|
565
|
+
method: request.method,
|
|
566
|
+
path,
|
|
567
|
+
port: request.port,
|
|
568
|
+
agent,
|
|
569
|
+
auth
|
|
570
|
+
};
|
|
571
|
+
const requestFunc = isSSL ? import_https.request : import_http.request;
|
|
572
|
+
const req = requestFunc(nodeHttpsOptions, (res) => {
|
|
573
|
+
const httpResponse = new import_protocol_http.HttpResponse({
|
|
574
|
+
statusCode: res.statusCode || -1,
|
|
575
|
+
reason: res.statusMessage,
|
|
576
|
+
headers: getTransformedHeaders(res.headers),
|
|
577
|
+
body: res
|
|
578
|
+
});
|
|
579
|
+
resolve({ response: httpResponse });
|
|
580
|
+
});
|
|
581
|
+
req.on("error", (err) => {
|
|
582
|
+
if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
|
|
583
|
+
reject(Object.assign(err, { name: "TimeoutError" }));
|
|
584
|
+
} else {
|
|
585
|
+
reject(err);
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
if (abortSignal) {
|
|
589
|
+
const onAbort = /* @__PURE__ */ __name(() => {
|
|
590
|
+
req.destroy();
|
|
591
|
+
const abortError = new Error("Request aborted");
|
|
592
|
+
abortError.name = "AbortError";
|
|
593
|
+
reject(abortError);
|
|
594
|
+
}, "onAbort");
|
|
595
|
+
if (typeof abortSignal.addEventListener === "function") {
|
|
596
|
+
const signal = abortSignal;
|
|
597
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
598
|
+
req.once("close", () => signal.removeEventListener("abort", onAbort));
|
|
599
|
+
} else {
|
|
600
|
+
abortSignal.onabort = onAbort;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
timeouts.push(setConnectionTimeout(req, reject, this.config.connectionTimeout));
|
|
604
|
+
timeouts.push(setSocketTimeout(req, reject, this.config.requestTimeout));
|
|
605
|
+
const httpAgent = nodeHttpsOptions.agent;
|
|
606
|
+
if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
|
|
607
|
+
timeouts.push(setSocketKeepAlive(req, {
|
|
608
|
+
keepAlive: httpAgent.keepAlive,
|
|
609
|
+
keepAliveMsecs: httpAgent.keepAliveMsecs
|
|
610
|
+
}));
|
|
611
|
+
}
|
|
612
|
+
writeRequestBodyPromise = writeRequestBody(req, request, this.config.requestTimeout).catch((e) => {
|
|
613
|
+
timeouts.forEach(timing.clearTimeout);
|
|
614
|
+
return _reject(e);
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
updateHttpClientConfig(key, value) {
|
|
619
|
+
this.config = undefined;
|
|
620
|
+
this.configProvider = this.configProvider.then((config) => {
|
|
621
|
+
return {
|
|
622
|
+
...config,
|
|
623
|
+
[key]: value
|
|
624
|
+
};
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
httpHandlerConfigs() {
|
|
628
|
+
return this.config ?? {};
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
var import_http22 = __require("node:http2");
|
|
632
|
+
var import_http2 = __toESM(__require("node:http2"));
|
|
633
|
+
var NodeHttp2ConnectionPool = class {
|
|
634
|
+
constructor(sessions) {
|
|
635
|
+
this.sessions = [];
|
|
636
|
+
this.sessions = sessions ?? [];
|
|
637
|
+
}
|
|
638
|
+
static {
|
|
639
|
+
__name(this, "NodeHttp2ConnectionPool");
|
|
640
|
+
}
|
|
641
|
+
poll() {
|
|
642
|
+
if (this.sessions.length > 0) {
|
|
643
|
+
return this.sessions.shift();
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
offerLast(session) {
|
|
647
|
+
this.sessions.push(session);
|
|
648
|
+
}
|
|
649
|
+
contains(session) {
|
|
650
|
+
return this.sessions.includes(session);
|
|
651
|
+
}
|
|
652
|
+
remove(session) {
|
|
653
|
+
this.sessions = this.sessions.filter((s) => s !== session);
|
|
654
|
+
}
|
|
655
|
+
[Symbol.iterator]() {
|
|
656
|
+
return this.sessions[Symbol.iterator]();
|
|
657
|
+
}
|
|
658
|
+
destroy(connection) {
|
|
659
|
+
for (const session of this.sessions) {
|
|
660
|
+
if (session === connection) {
|
|
661
|
+
if (!session.destroyed) {
|
|
662
|
+
session.destroy();
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
var NodeHttp2ConnectionManager = class {
|
|
669
|
+
constructor(config) {
|
|
670
|
+
this.sessionCache = /* @__PURE__ */ new Map;
|
|
671
|
+
this.config = config;
|
|
672
|
+
if (this.config.maxConcurrency && this.config.maxConcurrency <= 0) {
|
|
673
|
+
throw new RangeError("maxConcurrency must be greater than zero.");
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
static {
|
|
677
|
+
__name(this, "NodeHttp2ConnectionManager");
|
|
678
|
+
}
|
|
679
|
+
lease(requestContext, connectionConfiguration) {
|
|
680
|
+
const url = this.getUrlString(requestContext);
|
|
681
|
+
const existingPool = this.sessionCache.get(url);
|
|
682
|
+
if (existingPool) {
|
|
683
|
+
const existingSession = existingPool.poll();
|
|
684
|
+
if (existingSession && !this.config.disableConcurrency) {
|
|
685
|
+
return existingSession;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
const session = import_http2.default.connect(url);
|
|
689
|
+
if (this.config.maxConcurrency) {
|
|
690
|
+
session.settings({ maxConcurrentStreams: this.config.maxConcurrency }, (err) => {
|
|
691
|
+
if (err) {
|
|
692
|
+
throw new Error("Fail to set maxConcurrentStreams to " + this.config.maxConcurrency + "when creating new session for " + requestContext.destination.toString());
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
session.unref();
|
|
697
|
+
const destroySessionCb = /* @__PURE__ */ __name(() => {
|
|
698
|
+
session.destroy();
|
|
699
|
+
this.deleteSession(url, session);
|
|
700
|
+
}, "destroySessionCb");
|
|
701
|
+
session.on("goaway", destroySessionCb);
|
|
702
|
+
session.on("error", destroySessionCb);
|
|
703
|
+
session.on("frameError", destroySessionCb);
|
|
704
|
+
session.on("close", () => this.deleteSession(url, session));
|
|
705
|
+
if (connectionConfiguration.requestTimeout) {
|
|
706
|
+
session.setTimeout(connectionConfiguration.requestTimeout, destroySessionCb);
|
|
707
|
+
}
|
|
708
|
+
const connectionPool = this.sessionCache.get(url) || new NodeHttp2ConnectionPool;
|
|
709
|
+
connectionPool.offerLast(session);
|
|
710
|
+
this.sessionCache.set(url, connectionPool);
|
|
711
|
+
return session;
|
|
712
|
+
}
|
|
713
|
+
deleteSession(authority, session) {
|
|
714
|
+
const existingConnectionPool = this.sessionCache.get(authority);
|
|
715
|
+
if (!existingConnectionPool) {
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
if (!existingConnectionPool.contains(session)) {
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
existingConnectionPool.remove(session);
|
|
722
|
+
this.sessionCache.set(authority, existingConnectionPool);
|
|
723
|
+
}
|
|
724
|
+
release(requestContext, session) {
|
|
725
|
+
const cacheKey = this.getUrlString(requestContext);
|
|
726
|
+
this.sessionCache.get(cacheKey)?.offerLast(session);
|
|
727
|
+
}
|
|
728
|
+
destroy() {
|
|
729
|
+
for (const [key, connectionPool] of this.sessionCache) {
|
|
730
|
+
for (const session of connectionPool) {
|
|
731
|
+
if (!session.destroyed) {
|
|
732
|
+
session.destroy();
|
|
733
|
+
}
|
|
734
|
+
connectionPool.remove(session);
|
|
735
|
+
}
|
|
736
|
+
this.sessionCache.delete(key);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
setMaxConcurrentStreams(maxConcurrentStreams) {
|
|
740
|
+
if (maxConcurrentStreams && maxConcurrentStreams <= 0) {
|
|
741
|
+
throw new RangeError("maxConcurrentStreams must be greater than zero.");
|
|
742
|
+
}
|
|
743
|
+
this.config.maxConcurrency = maxConcurrentStreams;
|
|
744
|
+
}
|
|
745
|
+
setDisableConcurrentStreams(disableConcurrentStreams) {
|
|
746
|
+
this.config.disableConcurrency = disableConcurrentStreams;
|
|
747
|
+
}
|
|
748
|
+
getUrlString(request) {
|
|
749
|
+
return request.destination.toString();
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
var NodeHttp2Handler = class _NodeHttp2Handler {
|
|
753
|
+
constructor(options) {
|
|
754
|
+
this.metadata = { handlerProtocol: "h2" };
|
|
755
|
+
this.connectionManager = new NodeHttp2ConnectionManager({});
|
|
756
|
+
this.configProvider = new Promise((resolve, reject) => {
|
|
757
|
+
if (typeof options === "function") {
|
|
758
|
+
options().then((opts) => {
|
|
759
|
+
resolve(opts || {});
|
|
760
|
+
}).catch(reject);
|
|
761
|
+
} else {
|
|
762
|
+
resolve(options || {});
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
static {
|
|
767
|
+
__name(this, "NodeHttp2Handler");
|
|
768
|
+
}
|
|
769
|
+
static create(instanceOrOptions) {
|
|
770
|
+
if (typeof instanceOrOptions?.handle === "function") {
|
|
771
|
+
return instanceOrOptions;
|
|
772
|
+
}
|
|
773
|
+
return new _NodeHttp2Handler(instanceOrOptions);
|
|
774
|
+
}
|
|
775
|
+
destroy() {
|
|
776
|
+
this.connectionManager.destroy();
|
|
777
|
+
}
|
|
778
|
+
async handle(request, { abortSignal } = {}) {
|
|
779
|
+
if (!this.config) {
|
|
780
|
+
this.config = await this.configProvider;
|
|
781
|
+
this.connectionManager.setDisableConcurrentStreams(this.config.disableConcurrentStreams || false);
|
|
782
|
+
if (this.config.maxConcurrentStreams) {
|
|
783
|
+
this.connectionManager.setMaxConcurrentStreams(this.config.maxConcurrentStreams);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
const { requestTimeout, disableConcurrentStreams } = this.config;
|
|
787
|
+
return new Promise((_resolve, _reject) => {
|
|
788
|
+
let fulfilled = false;
|
|
789
|
+
let writeRequestBodyPromise = undefined;
|
|
790
|
+
const resolve = /* @__PURE__ */ __name(async (arg) => {
|
|
791
|
+
await writeRequestBodyPromise;
|
|
792
|
+
_resolve(arg);
|
|
793
|
+
}, "resolve");
|
|
794
|
+
const reject = /* @__PURE__ */ __name(async (arg) => {
|
|
795
|
+
await writeRequestBodyPromise;
|
|
796
|
+
_reject(arg);
|
|
797
|
+
}, "reject");
|
|
798
|
+
if (abortSignal?.aborted) {
|
|
799
|
+
fulfilled = true;
|
|
800
|
+
const abortError = new Error("Request aborted");
|
|
801
|
+
abortError.name = "AbortError";
|
|
802
|
+
reject(abortError);
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
const { hostname, method, port, protocol, query } = request;
|
|
806
|
+
let auth = "";
|
|
807
|
+
if (request.username != null || request.password != null) {
|
|
808
|
+
const username = request.username ?? "";
|
|
809
|
+
const password = request.password ?? "";
|
|
810
|
+
auth = `${username}:${password}@`;
|
|
811
|
+
}
|
|
812
|
+
const authority = `${protocol}//${auth}${hostname}${port ? `:${port}` : ""}`;
|
|
813
|
+
const requestContext = { destination: new URL(authority) };
|
|
814
|
+
const session = this.connectionManager.lease(requestContext, {
|
|
815
|
+
requestTimeout: this.config?.sessionTimeout,
|
|
816
|
+
disableConcurrentStreams: disableConcurrentStreams || false
|
|
817
|
+
});
|
|
818
|
+
const rejectWithDestroy = /* @__PURE__ */ __name((err) => {
|
|
819
|
+
if (disableConcurrentStreams) {
|
|
820
|
+
this.destroySession(session);
|
|
821
|
+
}
|
|
822
|
+
fulfilled = true;
|
|
823
|
+
reject(err);
|
|
824
|
+
}, "rejectWithDestroy");
|
|
825
|
+
const queryString = (0, import_querystring_builder.buildQueryString)(query || {});
|
|
826
|
+
let path = request.path;
|
|
827
|
+
if (queryString) {
|
|
828
|
+
path += `?${queryString}`;
|
|
829
|
+
}
|
|
830
|
+
if (request.fragment) {
|
|
831
|
+
path += `#${request.fragment}`;
|
|
832
|
+
}
|
|
833
|
+
const req = session.request({
|
|
834
|
+
...request.headers,
|
|
835
|
+
[import_http22.constants.HTTP2_HEADER_PATH]: path,
|
|
836
|
+
[import_http22.constants.HTTP2_HEADER_METHOD]: method
|
|
837
|
+
});
|
|
838
|
+
session.ref();
|
|
839
|
+
req.on("response", (headers) => {
|
|
840
|
+
const httpResponse = new import_protocol_http.HttpResponse({
|
|
841
|
+
statusCode: headers[":status"] || -1,
|
|
842
|
+
headers: getTransformedHeaders(headers),
|
|
843
|
+
body: req
|
|
844
|
+
});
|
|
845
|
+
fulfilled = true;
|
|
846
|
+
resolve({ response: httpResponse });
|
|
847
|
+
if (disableConcurrentStreams) {
|
|
848
|
+
session.close();
|
|
849
|
+
this.connectionManager.deleteSession(authority, session);
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
if (requestTimeout) {
|
|
853
|
+
req.setTimeout(requestTimeout, () => {
|
|
854
|
+
req.close();
|
|
855
|
+
const timeoutError = new Error(`Stream timed out because of no activity for ${requestTimeout} ms`);
|
|
856
|
+
timeoutError.name = "TimeoutError";
|
|
857
|
+
rejectWithDestroy(timeoutError);
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
if (abortSignal) {
|
|
861
|
+
const onAbort = /* @__PURE__ */ __name(() => {
|
|
862
|
+
req.close();
|
|
863
|
+
const abortError = new Error("Request aborted");
|
|
864
|
+
abortError.name = "AbortError";
|
|
865
|
+
rejectWithDestroy(abortError);
|
|
866
|
+
}, "onAbort");
|
|
867
|
+
if (typeof abortSignal.addEventListener === "function") {
|
|
868
|
+
const signal = abortSignal;
|
|
869
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
870
|
+
req.once("close", () => signal.removeEventListener("abort", onAbort));
|
|
871
|
+
} else {
|
|
872
|
+
abortSignal.onabort = onAbort;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
req.on("frameError", (type, code, id) => {
|
|
876
|
+
rejectWithDestroy(new Error(`Frame type id ${type} in stream id ${id} has failed with code ${code}.`));
|
|
877
|
+
});
|
|
878
|
+
req.on("error", rejectWithDestroy);
|
|
879
|
+
req.on("aborted", () => {
|
|
880
|
+
rejectWithDestroy(new Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${req.rstCode}.`));
|
|
881
|
+
});
|
|
882
|
+
req.on("close", () => {
|
|
883
|
+
session.unref();
|
|
884
|
+
if (disableConcurrentStreams) {
|
|
885
|
+
session.destroy();
|
|
886
|
+
}
|
|
887
|
+
if (!fulfilled) {
|
|
888
|
+
rejectWithDestroy(new Error("Unexpected error: http2 request did not get a response"));
|
|
889
|
+
}
|
|
890
|
+
});
|
|
891
|
+
writeRequestBodyPromise = writeRequestBody(req, request, requestTimeout);
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
updateHttpClientConfig(key, value) {
|
|
895
|
+
this.config = undefined;
|
|
896
|
+
this.configProvider = this.configProvider.then((config) => {
|
|
897
|
+
return {
|
|
898
|
+
...config,
|
|
899
|
+
[key]: value
|
|
900
|
+
};
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
httpHandlerConfigs() {
|
|
904
|
+
return this.config ?? {};
|
|
905
|
+
}
|
|
906
|
+
destroySession(session) {
|
|
907
|
+
if (!session.destroyed) {
|
|
908
|
+
session.destroy();
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
var Collector = class extends import_stream.Writable {
|
|
913
|
+
constructor() {
|
|
914
|
+
super(...arguments);
|
|
915
|
+
this.bufferedBytes = [];
|
|
916
|
+
}
|
|
917
|
+
static {
|
|
918
|
+
__name(this, "Collector");
|
|
919
|
+
}
|
|
920
|
+
_write(chunk, encoding, callback) {
|
|
921
|
+
this.bufferedBytes.push(chunk);
|
|
922
|
+
callback();
|
|
923
|
+
}
|
|
924
|
+
};
|
|
925
|
+
var streamCollector = /* @__PURE__ */ __name((stream) => {
|
|
926
|
+
if (isReadableStreamInstance(stream)) {
|
|
927
|
+
return collectReadableStream(stream);
|
|
928
|
+
}
|
|
929
|
+
return new Promise((resolve, reject) => {
|
|
930
|
+
const collector = new Collector;
|
|
931
|
+
stream.pipe(collector);
|
|
932
|
+
stream.on("error", (err) => {
|
|
933
|
+
collector.end();
|
|
934
|
+
reject(err);
|
|
935
|
+
});
|
|
936
|
+
collector.on("error", reject);
|
|
937
|
+
collector.on("finish", function() {
|
|
938
|
+
const bytes = new Uint8Array(Buffer.concat(this.bufferedBytes));
|
|
939
|
+
resolve(bytes);
|
|
940
|
+
});
|
|
941
|
+
});
|
|
942
|
+
}, "streamCollector");
|
|
943
|
+
var isReadableStreamInstance = /* @__PURE__ */ __name((stream) => typeof ReadableStream === "function" && stream instanceof ReadableStream, "isReadableStreamInstance");
|
|
944
|
+
async function collectReadableStream(stream) {
|
|
945
|
+
const chunks = [];
|
|
946
|
+
const reader = stream.getReader();
|
|
947
|
+
let isDone = false;
|
|
948
|
+
let length = 0;
|
|
949
|
+
while (!isDone) {
|
|
950
|
+
const { done, value } = await reader.read();
|
|
951
|
+
if (value) {
|
|
952
|
+
chunks.push(value);
|
|
953
|
+
length += value.length;
|
|
954
|
+
}
|
|
955
|
+
isDone = done;
|
|
956
|
+
}
|
|
957
|
+
const collected = new Uint8Array(length);
|
|
958
|
+
let offset = 0;
|
|
959
|
+
for (const chunk of chunks) {
|
|
960
|
+
collected.set(chunk, offset);
|
|
961
|
+
offset += chunk.length;
|
|
962
|
+
}
|
|
963
|
+
return collected;
|
|
964
|
+
}
|
|
965
|
+
__name(collectReadableStream, "collectReadableStream");
|
|
966
|
+
});
|
|
967
|
+
|
|
968
|
+
// ../../../../node_modules/@smithy/is-array-buffer/dist-cjs/index.js
|
|
969
|
+
var require_dist_cjs6 = __commonJS((exports, module) => {
|
|
970
|
+
var __defProp = Object.defineProperty;
|
|
971
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
972
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
973
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
974
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
975
|
+
var __export = (target, all) => {
|
|
976
|
+
for (var name in all)
|
|
977
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
978
|
+
};
|
|
979
|
+
var __copyProps = (to, from, except, desc) => {
|
|
980
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
981
|
+
for (let key of __getOwnPropNames(from))
|
|
982
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
983
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
984
|
+
}
|
|
985
|
+
return to;
|
|
986
|
+
};
|
|
987
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
988
|
+
var src_exports = {};
|
|
989
|
+
__export(src_exports, {
|
|
990
|
+
isArrayBuffer: () => isArrayBuffer
|
|
991
|
+
});
|
|
992
|
+
module.exports = __toCommonJS(src_exports);
|
|
993
|
+
var isArrayBuffer = /* @__PURE__ */ __name((arg) => typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer || Object.prototype.toString.call(arg) === "[object ArrayBuffer]", "isArrayBuffer");
|
|
994
|
+
});
|
|
995
|
+
|
|
996
|
+
// ../../../../node_modules/@smithy/util-buffer-from/dist-cjs/index.js
|
|
997
|
+
var require_dist_cjs7 = __commonJS((exports, module) => {
|
|
998
|
+
var __defProp = Object.defineProperty;
|
|
999
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
1000
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
1001
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1002
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1003
|
+
var __export = (target, all) => {
|
|
1004
|
+
for (var name in all)
|
|
1005
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
1006
|
+
};
|
|
1007
|
+
var __copyProps = (to, from, except, desc) => {
|
|
1008
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
1009
|
+
for (let key of __getOwnPropNames(from))
|
|
1010
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
1011
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
1012
|
+
}
|
|
1013
|
+
return to;
|
|
1014
|
+
};
|
|
1015
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1016
|
+
var src_exports = {};
|
|
1017
|
+
__export(src_exports, {
|
|
1018
|
+
fromArrayBuffer: () => fromArrayBuffer,
|
|
1019
|
+
fromString: () => fromString
|
|
1020
|
+
});
|
|
1021
|
+
module.exports = __toCommonJS(src_exports);
|
|
1022
|
+
var import_is_array_buffer = require_dist_cjs6();
|
|
1023
|
+
var import_buffer = __require("node:buffer");
|
|
1024
|
+
var fromArrayBuffer = /* @__PURE__ */ __name((input, offset = 0, length = input.byteLength - offset) => {
|
|
1025
|
+
if (!(0, import_is_array_buffer.isArrayBuffer)(input)) {
|
|
1026
|
+
throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof input} (${input})`);
|
|
1027
|
+
}
|
|
1028
|
+
return import_buffer.Buffer.from(input, offset, length);
|
|
1029
|
+
}, "fromArrayBuffer");
|
|
1030
|
+
var fromString = /* @__PURE__ */ __name((input, encoding) => {
|
|
1031
|
+
if (typeof input !== "string") {
|
|
1032
|
+
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
|
|
1033
|
+
}
|
|
1034
|
+
return encoding ? import_buffer.Buffer.from(input, encoding) : import_buffer.Buffer.from(input);
|
|
1035
|
+
}, "fromString");
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1038
|
+
// ../../../../node_modules/@smithy/util-base64/dist-cjs/fromBase64.js
|
|
1039
|
+
var require_fromBase64 = __commonJS((exports) => {
|
|
1040
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1041
|
+
exports.fromBase64 = undefined;
|
|
1042
|
+
var util_buffer_from_1 = require_dist_cjs7();
|
|
1043
|
+
var BASE64_REGEX = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
1044
|
+
var fromBase642 = (input) => {
|
|
1045
|
+
if (input.length * 3 % 4 !== 0) {
|
|
1046
|
+
throw new TypeError(`Incorrect padding on base64 string.`);
|
|
1047
|
+
}
|
|
1048
|
+
if (!BASE64_REGEX.exec(input)) {
|
|
1049
|
+
throw new TypeError(`Invalid base64 string.`);
|
|
1050
|
+
}
|
|
1051
|
+
const buffer = (0, util_buffer_from_1.fromString)(input, "base64");
|
|
1052
|
+
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
1053
|
+
};
|
|
1054
|
+
exports.fromBase64 = fromBase642;
|
|
1055
|
+
});
|
|
1056
|
+
|
|
1057
|
+
// ../../../../node_modules/@smithy/util-utf8/dist-cjs/index.js
|
|
1058
|
+
var require_dist_cjs8 = __commonJS((exports, module) => {
|
|
1059
|
+
var __defProp = Object.defineProperty;
|
|
1060
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
1061
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
1062
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1063
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1064
|
+
var __export = (target, all) => {
|
|
1065
|
+
for (var name in all)
|
|
1066
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
1067
|
+
};
|
|
1068
|
+
var __copyProps = (to, from, except, desc) => {
|
|
1069
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
1070
|
+
for (let key of __getOwnPropNames(from))
|
|
1071
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
1072
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
1073
|
+
}
|
|
1074
|
+
return to;
|
|
1075
|
+
};
|
|
1076
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1077
|
+
var src_exports = {};
|
|
1078
|
+
__export(src_exports, {
|
|
1079
|
+
fromUtf8: () => fromUtf8,
|
|
1080
|
+
toUint8Array: () => toUint8Array,
|
|
1081
|
+
toUtf8: () => toUtf8
|
|
1082
|
+
});
|
|
1083
|
+
module.exports = __toCommonJS(src_exports);
|
|
1084
|
+
var import_util_buffer_from = require_dist_cjs7();
|
|
1085
|
+
var fromUtf8 = /* @__PURE__ */ __name((input) => {
|
|
1086
|
+
const buf = (0, import_util_buffer_from.fromString)(input, "utf8");
|
|
1087
|
+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
1088
|
+
}, "fromUtf8");
|
|
1089
|
+
var toUint8Array = /* @__PURE__ */ __name((data) => {
|
|
1090
|
+
if (typeof data === "string") {
|
|
1091
|
+
return fromUtf8(data);
|
|
1092
|
+
}
|
|
1093
|
+
if (ArrayBuffer.isView(data)) {
|
|
1094
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
1095
|
+
}
|
|
1096
|
+
return new Uint8Array(data);
|
|
1097
|
+
}, "toUint8Array");
|
|
1098
|
+
var toUtf8 = /* @__PURE__ */ __name((input) => {
|
|
1099
|
+
if (typeof input === "string") {
|
|
1100
|
+
return input;
|
|
1101
|
+
}
|
|
1102
|
+
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
1103
|
+
throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");
|
|
1104
|
+
}
|
|
1105
|
+
return (0, import_util_buffer_from.fromArrayBuffer)(input.buffer, input.byteOffset, input.byteLength).toString("utf8");
|
|
1106
|
+
}, "toUtf8");
|
|
1107
|
+
});
|
|
1108
|
+
|
|
1109
|
+
// ../../../../node_modules/@smithy/util-base64/dist-cjs/toBase64.js
|
|
1110
|
+
var require_toBase64 = __commonJS((exports) => {
|
|
1111
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1112
|
+
exports.toBase64 = undefined;
|
|
1113
|
+
var util_buffer_from_1 = require_dist_cjs7();
|
|
1114
|
+
var util_utf8_1 = require_dist_cjs8();
|
|
1115
|
+
var toBase642 = (_input) => {
|
|
1116
|
+
let input;
|
|
1117
|
+
if (typeof _input === "string") {
|
|
1118
|
+
input = (0, util_utf8_1.fromUtf8)(_input);
|
|
1119
|
+
} else {
|
|
1120
|
+
input = _input;
|
|
1121
|
+
}
|
|
1122
|
+
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
1123
|
+
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");
|
|
1124
|
+
}
|
|
1125
|
+
return (0, util_buffer_from_1.fromArrayBuffer)(input.buffer, input.byteOffset, input.byteLength).toString("base64");
|
|
1126
|
+
};
|
|
1127
|
+
exports.toBase64 = toBase642;
|
|
1128
|
+
});
|
|
1129
|
+
|
|
1130
|
+
// ../../../../node_modules/@smithy/util-base64/dist-cjs/index.js
|
|
1131
|
+
var require_dist_cjs9 = __commonJS((exports, module) => {
|
|
1132
|
+
var __defProp = Object.defineProperty;
|
|
1133
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
1134
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
1135
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1136
|
+
var __copyProps = (to, from, except, desc) => {
|
|
1137
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
1138
|
+
for (let key of __getOwnPropNames(from))
|
|
1139
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
1140
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
1141
|
+
}
|
|
1142
|
+
return to;
|
|
1143
|
+
};
|
|
1144
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
1145
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1146
|
+
var src_exports = {};
|
|
1147
|
+
module.exports = __toCommonJS(src_exports);
|
|
1148
|
+
__reExport(src_exports, require_fromBase64(), module.exports);
|
|
1149
|
+
__reExport(src_exports, require_toBase64(), module.exports);
|
|
1150
|
+
});
|
|
1151
|
+
|
|
1152
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/checksum/ChecksumStream.js
|
|
1153
|
+
var require_ChecksumStream = __commonJS((exports) => {
|
|
1154
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1155
|
+
exports.ChecksumStream = undefined;
|
|
1156
|
+
var util_base64_1 = require_dist_cjs9();
|
|
1157
|
+
var stream_1 = __require("node:stream");
|
|
1158
|
+
|
|
1159
|
+
class ChecksumStream2 extends stream_1.Duplex {
|
|
1160
|
+
constructor({ expectedChecksum, checksum, source, checksumSourceLocation, base64Encoder }) {
|
|
1161
|
+
var _a, _b;
|
|
1162
|
+
super();
|
|
1163
|
+
if (typeof source.pipe === "function") {
|
|
1164
|
+
this.source = source;
|
|
1165
|
+
} else {
|
|
1166
|
+
throw new Error(`@smithy/util-stream: unsupported source type ${(_b = (_a = source === null || source === undefined ? undefined : source.constructor) === null || _a === undefined ? undefined : _a.name) !== null && _b !== undefined ? _b : source} in ChecksumStream.`);
|
|
1167
|
+
}
|
|
1168
|
+
this.base64Encoder = base64Encoder !== null && base64Encoder !== undefined ? base64Encoder : util_base64_1.toBase64;
|
|
1169
|
+
this.expectedChecksum = expectedChecksum;
|
|
1170
|
+
this.checksum = checksum;
|
|
1171
|
+
this.checksumSourceLocation = checksumSourceLocation;
|
|
1172
|
+
this.source.pipe(this);
|
|
1173
|
+
}
|
|
1174
|
+
_read(size) {}
|
|
1175
|
+
_write(chunk, encoding, callback) {
|
|
1176
|
+
try {
|
|
1177
|
+
this.checksum.update(chunk);
|
|
1178
|
+
this.push(chunk);
|
|
1179
|
+
} catch (e) {
|
|
1180
|
+
return callback(e);
|
|
1181
|
+
}
|
|
1182
|
+
return callback();
|
|
1183
|
+
}
|
|
1184
|
+
async _final(callback) {
|
|
1185
|
+
try {
|
|
1186
|
+
const digest = await this.checksum.digest();
|
|
1187
|
+
const received = this.base64Encoder(digest);
|
|
1188
|
+
if (this.expectedChecksum !== received) {
|
|
1189
|
+
return callback(new Error(`Checksum mismatch: expected "${this.expectedChecksum}" but received "${received}"` + ` in response header "${this.checksumSourceLocation}".`));
|
|
1190
|
+
}
|
|
1191
|
+
} catch (e) {
|
|
1192
|
+
return callback(e);
|
|
1193
|
+
}
|
|
1194
|
+
this.push(null);
|
|
1195
|
+
return callback();
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
exports.ChecksumStream = ChecksumStream2;
|
|
1199
|
+
});
|
|
1200
|
+
|
|
1201
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/stream-type-check.js
|
|
1202
|
+
var require_stream_type_check = __commonJS((exports) => {
|
|
1203
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1204
|
+
exports.isBlob = exports.isReadableStream = undefined;
|
|
1205
|
+
var isReadableStream2 = (stream) => {
|
|
1206
|
+
var _a;
|
|
1207
|
+
return typeof ReadableStream === "function" && (((_a = stream === null || stream === undefined ? undefined : stream.constructor) === null || _a === undefined ? undefined : _a.name) === ReadableStream.name || stream instanceof ReadableStream);
|
|
1208
|
+
};
|
|
1209
|
+
exports.isReadableStream = isReadableStream2;
|
|
1210
|
+
var isBlob2 = (blob) => {
|
|
1211
|
+
var _a;
|
|
1212
|
+
return typeof Blob === "function" && (((_a = blob === null || blob === undefined ? undefined : blob.constructor) === null || _a === undefined ? undefined : _a.name) === Blob.name || blob instanceof Blob);
|
|
1213
|
+
};
|
|
1214
|
+
exports.isBlob = isBlob2;
|
|
1215
|
+
});
|
|
1216
|
+
|
|
1217
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/checksum/ChecksumStream.browser.js
|
|
1218
|
+
var require_ChecksumStream_browser = __commonJS((exports) => {
|
|
1219
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1220
|
+
exports.ChecksumStream = undefined;
|
|
1221
|
+
var ReadableStreamRef = typeof ReadableStream === "function" ? ReadableStream : function() {};
|
|
1222
|
+
|
|
1223
|
+
class ChecksumStream2 extends ReadableStreamRef {
|
|
1224
|
+
}
|
|
1225
|
+
exports.ChecksumStream = ChecksumStream2;
|
|
1226
|
+
});
|
|
1227
|
+
|
|
1228
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/checksum/createChecksumStream.browser.js
|
|
1229
|
+
var require_createChecksumStream_browser = __commonJS((exports) => {
|
|
1230
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1231
|
+
exports.createChecksumStream = undefined;
|
|
1232
|
+
var util_base64_1 = require_dist_cjs9();
|
|
1233
|
+
var stream_type_check_1 = require_stream_type_check();
|
|
1234
|
+
var ChecksumStream_browser_1 = require_ChecksumStream_browser();
|
|
1235
|
+
var createChecksumStream2 = ({ expectedChecksum, checksum, source, checksumSourceLocation, base64Encoder }) => {
|
|
1236
|
+
var _a, _b;
|
|
1237
|
+
if (!(0, stream_type_check_1.isReadableStream)(source)) {
|
|
1238
|
+
throw new Error(`@smithy/util-stream: unsupported source type ${(_b = (_a = source === null || source === undefined ? undefined : source.constructor) === null || _a === undefined ? undefined : _a.name) !== null && _b !== undefined ? _b : source} in ChecksumStream.`);
|
|
1239
|
+
}
|
|
1240
|
+
const encoder = base64Encoder !== null && base64Encoder !== undefined ? base64Encoder : util_base64_1.toBase64;
|
|
1241
|
+
if (typeof TransformStream !== "function") {
|
|
1242
|
+
throw new Error("@smithy/util-stream: unable to instantiate ChecksumStream because API unavailable: ReadableStream/TransformStream.");
|
|
1243
|
+
}
|
|
1244
|
+
const transform = new TransformStream({
|
|
1245
|
+
start() {},
|
|
1246
|
+
async transform(chunk, controller) {
|
|
1247
|
+
checksum.update(chunk);
|
|
1248
|
+
controller.enqueue(chunk);
|
|
1249
|
+
},
|
|
1250
|
+
async flush(controller) {
|
|
1251
|
+
const digest = await checksum.digest();
|
|
1252
|
+
const received = encoder(digest);
|
|
1253
|
+
if (expectedChecksum !== received) {
|
|
1254
|
+
const error = new Error(`Checksum mismatch: expected "${expectedChecksum}" but received "${received}"` + ` in response header "${checksumSourceLocation}".`);
|
|
1255
|
+
controller.error(error);
|
|
1256
|
+
} else {
|
|
1257
|
+
controller.terminate();
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
source.pipeThrough(transform);
|
|
1262
|
+
const readable = transform.readable;
|
|
1263
|
+
Object.setPrototypeOf(readable, ChecksumStream_browser_1.ChecksumStream.prototype);
|
|
1264
|
+
return readable;
|
|
1265
|
+
};
|
|
1266
|
+
exports.createChecksumStream = createChecksumStream2;
|
|
1267
|
+
});
|
|
1268
|
+
|
|
1269
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/checksum/createChecksumStream.js
|
|
1270
|
+
var require_createChecksumStream = __commonJS((exports) => {
|
|
1271
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1272
|
+
exports.createChecksumStream = undefined;
|
|
1273
|
+
var stream_type_check_1 = require_stream_type_check();
|
|
1274
|
+
var ChecksumStream_1 = require_ChecksumStream();
|
|
1275
|
+
var createChecksumStream_browser_1 = require_createChecksumStream_browser();
|
|
1276
|
+
function createChecksumStream2(init) {
|
|
1277
|
+
if (typeof ReadableStream === "function" && (0, stream_type_check_1.isReadableStream)(init.source)) {
|
|
1278
|
+
return (0, createChecksumStream_browser_1.createChecksumStream)(init);
|
|
1279
|
+
}
|
|
1280
|
+
return new ChecksumStream_1.ChecksumStream(init);
|
|
1281
|
+
}
|
|
1282
|
+
exports.createChecksumStream = createChecksumStream2;
|
|
1283
|
+
});
|
|
1284
|
+
|
|
1285
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/ByteArrayCollector.js
|
|
1286
|
+
var require_ByteArrayCollector = __commonJS((exports) => {
|
|
1287
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1288
|
+
exports.ByteArrayCollector = undefined;
|
|
1289
|
+
|
|
1290
|
+
class ByteArrayCollector {
|
|
1291
|
+
constructor(allocByteArray) {
|
|
1292
|
+
this.allocByteArray = allocByteArray;
|
|
1293
|
+
this.byteLength = 0;
|
|
1294
|
+
this.byteArrays = [];
|
|
1295
|
+
}
|
|
1296
|
+
push(byteArray) {
|
|
1297
|
+
this.byteArrays.push(byteArray);
|
|
1298
|
+
this.byteLength += byteArray.byteLength;
|
|
1299
|
+
}
|
|
1300
|
+
flush() {
|
|
1301
|
+
if (this.byteArrays.length === 1) {
|
|
1302
|
+
const bytes = this.byteArrays[0];
|
|
1303
|
+
this.reset();
|
|
1304
|
+
return bytes;
|
|
1305
|
+
}
|
|
1306
|
+
const aggregation = this.allocByteArray(this.byteLength);
|
|
1307
|
+
let cursor = 0;
|
|
1308
|
+
for (let i = 0;i < this.byteArrays.length; ++i) {
|
|
1309
|
+
const bytes = this.byteArrays[i];
|
|
1310
|
+
aggregation.set(bytes, cursor);
|
|
1311
|
+
cursor += bytes.byteLength;
|
|
1312
|
+
}
|
|
1313
|
+
this.reset();
|
|
1314
|
+
return aggregation;
|
|
1315
|
+
}
|
|
1316
|
+
reset() {
|
|
1317
|
+
this.byteArrays = [];
|
|
1318
|
+
this.byteLength = 0;
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
exports.ByteArrayCollector = ByteArrayCollector;
|
|
1322
|
+
});
|
|
1323
|
+
|
|
1324
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/createBufferedReadableStream.js
|
|
1325
|
+
var require_createBufferedReadableStream = __commonJS((exports) => {
|
|
1326
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1327
|
+
exports.modeOf = exports.sizeOf = exports.flush = exports.merge = exports.createBufferedReadable = exports.createBufferedReadableStream = undefined;
|
|
1328
|
+
var ByteArrayCollector_1 = require_ByteArrayCollector();
|
|
1329
|
+
function createBufferedReadableStream(upstream, size, logger) {
|
|
1330
|
+
const reader = upstream.getReader();
|
|
1331
|
+
let streamBufferingLoggedWarning = false;
|
|
1332
|
+
let bytesSeen = 0;
|
|
1333
|
+
const buffers = ["", new ByteArrayCollector_1.ByteArrayCollector((size2) => new Uint8Array(size2))];
|
|
1334
|
+
let mode = -1;
|
|
1335
|
+
const pull = async (controller) => {
|
|
1336
|
+
const { value, done } = await reader.read();
|
|
1337
|
+
const chunk = value;
|
|
1338
|
+
if (done) {
|
|
1339
|
+
if (mode !== -1) {
|
|
1340
|
+
const remainder = flush(buffers, mode);
|
|
1341
|
+
if (sizeOf(remainder) > 0) {
|
|
1342
|
+
controller.enqueue(remainder);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
controller.close();
|
|
1346
|
+
} else {
|
|
1347
|
+
const chunkMode = modeOf(chunk, false);
|
|
1348
|
+
if (mode !== chunkMode) {
|
|
1349
|
+
if (mode >= 0) {
|
|
1350
|
+
controller.enqueue(flush(buffers, mode));
|
|
1351
|
+
}
|
|
1352
|
+
mode = chunkMode;
|
|
1353
|
+
}
|
|
1354
|
+
if (mode === -1) {
|
|
1355
|
+
controller.enqueue(chunk);
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
1358
|
+
const chunkSize = sizeOf(chunk);
|
|
1359
|
+
bytesSeen += chunkSize;
|
|
1360
|
+
const bufferSize = sizeOf(buffers[mode]);
|
|
1361
|
+
if (chunkSize >= size && bufferSize === 0) {
|
|
1362
|
+
controller.enqueue(chunk);
|
|
1363
|
+
} else {
|
|
1364
|
+
const newSize = merge(buffers, mode, chunk);
|
|
1365
|
+
if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
|
|
1366
|
+
streamBufferingLoggedWarning = true;
|
|
1367
|
+
logger === null || logger === undefined || logger.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
|
|
1368
|
+
}
|
|
1369
|
+
if (newSize >= size) {
|
|
1370
|
+
controller.enqueue(flush(buffers, mode));
|
|
1371
|
+
} else {
|
|
1372
|
+
await pull(controller);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
};
|
|
1377
|
+
return new ReadableStream({
|
|
1378
|
+
pull
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
exports.createBufferedReadableStream = createBufferedReadableStream;
|
|
1382
|
+
exports.createBufferedReadable = createBufferedReadableStream;
|
|
1383
|
+
function merge(buffers, mode, chunk) {
|
|
1384
|
+
switch (mode) {
|
|
1385
|
+
case 0:
|
|
1386
|
+
buffers[0] += chunk;
|
|
1387
|
+
return sizeOf(buffers[0]);
|
|
1388
|
+
case 1:
|
|
1389
|
+
case 2:
|
|
1390
|
+
buffers[mode].push(chunk);
|
|
1391
|
+
return sizeOf(buffers[mode]);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
exports.merge = merge;
|
|
1395
|
+
function flush(buffers, mode) {
|
|
1396
|
+
switch (mode) {
|
|
1397
|
+
case 0:
|
|
1398
|
+
const s = buffers[0];
|
|
1399
|
+
buffers[0] = "";
|
|
1400
|
+
return s;
|
|
1401
|
+
case 1:
|
|
1402
|
+
case 2:
|
|
1403
|
+
return buffers[mode].flush();
|
|
1404
|
+
}
|
|
1405
|
+
throw new Error(`@smithy/util-stream - invalid index ${mode} given to flush()`);
|
|
1406
|
+
}
|
|
1407
|
+
exports.flush = flush;
|
|
1408
|
+
function sizeOf(chunk) {
|
|
1409
|
+
var _a, _b;
|
|
1410
|
+
return (_b = (_a = chunk === null || chunk === undefined ? undefined : chunk.byteLength) !== null && _a !== undefined ? _a : chunk === null || chunk === undefined ? undefined : chunk.length) !== null && _b !== undefined ? _b : 0;
|
|
1411
|
+
}
|
|
1412
|
+
exports.sizeOf = sizeOf;
|
|
1413
|
+
function modeOf(chunk, allowBuffer = true) {
|
|
1414
|
+
if (allowBuffer && typeof Buffer !== "undefined" && chunk instanceof Buffer) {
|
|
1415
|
+
return 2;
|
|
1416
|
+
}
|
|
1417
|
+
if (chunk instanceof Uint8Array) {
|
|
1418
|
+
return 1;
|
|
1419
|
+
}
|
|
1420
|
+
if (typeof chunk === "string") {
|
|
1421
|
+
return 0;
|
|
1422
|
+
}
|
|
1423
|
+
return -1;
|
|
1424
|
+
}
|
|
1425
|
+
exports.modeOf = modeOf;
|
|
1426
|
+
});
|
|
1427
|
+
|
|
1428
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/createBufferedReadable.js
|
|
1429
|
+
var require_createBufferedReadable = __commonJS((exports) => {
|
|
1430
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1431
|
+
exports.createBufferedReadable = undefined;
|
|
1432
|
+
var node_stream_1 = __require("node:stream");
|
|
1433
|
+
var ByteArrayCollector_1 = require_ByteArrayCollector();
|
|
1434
|
+
var createBufferedReadableStream_1 = require_createBufferedReadableStream();
|
|
1435
|
+
var stream_type_check_1 = require_stream_type_check();
|
|
1436
|
+
function createBufferedReadable2(upstream, size, logger) {
|
|
1437
|
+
if ((0, stream_type_check_1.isReadableStream)(upstream)) {
|
|
1438
|
+
return (0, createBufferedReadableStream_1.createBufferedReadableStream)(upstream, size, logger);
|
|
1439
|
+
}
|
|
1440
|
+
const downstream = new node_stream_1.Readable({ read() {} });
|
|
1441
|
+
let streamBufferingLoggedWarning = false;
|
|
1442
|
+
let bytesSeen = 0;
|
|
1443
|
+
const buffers = [
|
|
1444
|
+
"",
|
|
1445
|
+
new ByteArrayCollector_1.ByteArrayCollector((size2) => new Uint8Array(size2)),
|
|
1446
|
+
new ByteArrayCollector_1.ByteArrayCollector((size2) => Buffer.from(new Uint8Array(size2)))
|
|
1447
|
+
];
|
|
1448
|
+
let mode = -1;
|
|
1449
|
+
upstream.on("data", (chunk) => {
|
|
1450
|
+
const chunkMode = (0, createBufferedReadableStream_1.modeOf)(chunk, true);
|
|
1451
|
+
if (mode !== chunkMode) {
|
|
1452
|
+
if (mode >= 0) {
|
|
1453
|
+
downstream.push((0, createBufferedReadableStream_1.flush)(buffers, mode));
|
|
1454
|
+
}
|
|
1455
|
+
mode = chunkMode;
|
|
1456
|
+
}
|
|
1457
|
+
if (mode === -1) {
|
|
1458
|
+
downstream.push(chunk);
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
const chunkSize = (0, createBufferedReadableStream_1.sizeOf)(chunk);
|
|
1462
|
+
bytesSeen += chunkSize;
|
|
1463
|
+
const bufferSize = (0, createBufferedReadableStream_1.sizeOf)(buffers[mode]);
|
|
1464
|
+
if (chunkSize >= size && bufferSize === 0) {
|
|
1465
|
+
downstream.push(chunk);
|
|
1466
|
+
} else {
|
|
1467
|
+
const newSize = (0, createBufferedReadableStream_1.merge)(buffers, mode, chunk);
|
|
1468
|
+
if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
|
|
1469
|
+
streamBufferingLoggedWarning = true;
|
|
1470
|
+
logger === null || logger === undefined || logger.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
|
|
1471
|
+
}
|
|
1472
|
+
if (newSize >= size) {
|
|
1473
|
+
downstream.push((0, createBufferedReadableStream_1.flush)(buffers, mode));
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
});
|
|
1477
|
+
upstream.on("end", () => {
|
|
1478
|
+
if (mode !== -1) {
|
|
1479
|
+
const remainder = (0, createBufferedReadableStream_1.flush)(buffers, mode);
|
|
1480
|
+
if ((0, createBufferedReadableStream_1.sizeOf)(remainder) > 0) {
|
|
1481
|
+
downstream.push(remainder);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
downstream.push(null);
|
|
1485
|
+
});
|
|
1486
|
+
return downstream;
|
|
1487
|
+
}
|
|
1488
|
+
exports.createBufferedReadable = createBufferedReadable2;
|
|
1489
|
+
});
|
|
1490
|
+
|
|
1491
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/getAwsChunkedEncodingStream.js
|
|
1492
|
+
var require_getAwsChunkedEncodingStream = __commonJS((exports) => {
|
|
1493
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1494
|
+
exports.getAwsChunkedEncodingStream = undefined;
|
|
1495
|
+
var stream_1 = __require("node:stream");
|
|
1496
|
+
var getAwsChunkedEncodingStream2 = (readableStream, options) => {
|
|
1497
|
+
const { base64Encoder, bodyLengthChecker, checksumAlgorithmFn, checksumLocationName, streamHasher } = options;
|
|
1498
|
+
const checksumRequired = base64Encoder !== undefined && checksumAlgorithmFn !== undefined && checksumLocationName !== undefined && streamHasher !== undefined;
|
|
1499
|
+
const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readableStream) : undefined;
|
|
1500
|
+
const awsChunkedEncodingStream = new stream_1.Readable({ read: () => {} });
|
|
1501
|
+
readableStream.on("data", (data) => {
|
|
1502
|
+
const length = bodyLengthChecker(data) || 0;
|
|
1503
|
+
awsChunkedEncodingStream.push(`${length.toString(16)}\r
|
|
1504
|
+
`);
|
|
1505
|
+
awsChunkedEncodingStream.push(data);
|
|
1506
|
+
awsChunkedEncodingStream.push(`\r
|
|
1507
|
+
`);
|
|
1508
|
+
});
|
|
1509
|
+
readableStream.on("end", async () => {
|
|
1510
|
+
awsChunkedEncodingStream.push(`0\r
|
|
1511
|
+
`);
|
|
1512
|
+
if (checksumRequired) {
|
|
1513
|
+
const checksum = base64Encoder(await digest);
|
|
1514
|
+
awsChunkedEncodingStream.push(`${checksumLocationName}:${checksum}\r
|
|
1515
|
+
`);
|
|
1516
|
+
awsChunkedEncodingStream.push(`\r
|
|
1517
|
+
`);
|
|
1518
|
+
}
|
|
1519
|
+
awsChunkedEncodingStream.push(null);
|
|
1520
|
+
});
|
|
1521
|
+
return awsChunkedEncodingStream;
|
|
1522
|
+
};
|
|
1523
|
+
exports.getAwsChunkedEncodingStream = getAwsChunkedEncodingStream2;
|
|
1524
|
+
});
|
|
1525
|
+
|
|
1526
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/headStream.browser.js
|
|
1527
|
+
var require_headStream_browser = __commonJS((exports) => {
|
|
1528
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1529
|
+
exports.headStream = undefined;
|
|
1530
|
+
async function headStream2(stream, bytes) {
|
|
1531
|
+
var _a;
|
|
1532
|
+
let byteLengthCounter = 0;
|
|
1533
|
+
const chunks = [];
|
|
1534
|
+
const reader = stream.getReader();
|
|
1535
|
+
let isDone = false;
|
|
1536
|
+
while (!isDone) {
|
|
1537
|
+
const { done, value } = await reader.read();
|
|
1538
|
+
if (value) {
|
|
1539
|
+
chunks.push(value);
|
|
1540
|
+
byteLengthCounter += (_a = value === null || value === undefined ? undefined : value.byteLength) !== null && _a !== undefined ? _a : 0;
|
|
1541
|
+
}
|
|
1542
|
+
if (byteLengthCounter >= bytes) {
|
|
1543
|
+
break;
|
|
1544
|
+
}
|
|
1545
|
+
isDone = done;
|
|
1546
|
+
}
|
|
1547
|
+
reader.releaseLock();
|
|
1548
|
+
const collected = new Uint8Array(Math.min(bytes, byteLengthCounter));
|
|
1549
|
+
let offset = 0;
|
|
1550
|
+
for (const chunk of chunks) {
|
|
1551
|
+
if (chunk.byteLength > collected.byteLength - offset) {
|
|
1552
|
+
collected.set(chunk.subarray(0, collected.byteLength - offset), offset);
|
|
1553
|
+
break;
|
|
1554
|
+
} else {
|
|
1555
|
+
collected.set(chunk, offset);
|
|
1556
|
+
}
|
|
1557
|
+
offset += chunk.length;
|
|
1558
|
+
}
|
|
1559
|
+
return collected;
|
|
1560
|
+
}
|
|
1561
|
+
exports.headStream = headStream2;
|
|
1562
|
+
});
|
|
1563
|
+
|
|
1564
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/headStream.js
|
|
1565
|
+
var require_headStream = __commonJS((exports) => {
|
|
1566
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1567
|
+
exports.headStream = undefined;
|
|
1568
|
+
var stream_1 = __require("node:stream");
|
|
1569
|
+
var headStream_browser_1 = require_headStream_browser();
|
|
1570
|
+
var stream_type_check_1 = require_stream_type_check();
|
|
1571
|
+
var headStream2 = (stream, bytes) => {
|
|
1572
|
+
if ((0, stream_type_check_1.isReadableStream)(stream)) {
|
|
1573
|
+
return (0, headStream_browser_1.headStream)(stream, bytes);
|
|
1574
|
+
}
|
|
1575
|
+
return new Promise((resolve, reject) => {
|
|
1576
|
+
const collector = new Collector;
|
|
1577
|
+
collector.limit = bytes;
|
|
1578
|
+
stream.pipe(collector);
|
|
1579
|
+
stream.on("error", (err) => {
|
|
1580
|
+
collector.end();
|
|
1581
|
+
reject(err);
|
|
1582
|
+
});
|
|
1583
|
+
collector.on("error", reject);
|
|
1584
|
+
collector.on("finish", function() {
|
|
1585
|
+
const bytes2 = new Uint8Array(Buffer.concat(this.buffers));
|
|
1586
|
+
resolve(bytes2);
|
|
1587
|
+
});
|
|
1588
|
+
});
|
|
1589
|
+
};
|
|
1590
|
+
exports.headStream = headStream2;
|
|
1591
|
+
|
|
1592
|
+
class Collector extends stream_1.Writable {
|
|
1593
|
+
constructor() {
|
|
1594
|
+
super(...arguments);
|
|
1595
|
+
this.buffers = [];
|
|
1596
|
+
this.limit = Infinity;
|
|
1597
|
+
this.bytesBuffered = 0;
|
|
1598
|
+
}
|
|
1599
|
+
_write(chunk, encoding, callback) {
|
|
1600
|
+
var _a;
|
|
1601
|
+
this.buffers.push(chunk);
|
|
1602
|
+
this.bytesBuffered += (_a = chunk.byteLength) !== null && _a !== undefined ? _a : 0;
|
|
1603
|
+
if (this.bytesBuffered >= this.limit) {
|
|
1604
|
+
const excess = this.bytesBuffered - this.limit;
|
|
1605
|
+
const tailBuffer = this.buffers[this.buffers.length - 1];
|
|
1606
|
+
this.buffers[this.buffers.length - 1] = tailBuffer.subarray(0, tailBuffer.byteLength - excess);
|
|
1607
|
+
this.emit("finish");
|
|
1608
|
+
}
|
|
1609
|
+
callback();
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
});
|
|
1613
|
+
|
|
1614
|
+
// ../../../../node_modules/@smithy/fetch-http-handler/dist-cjs/index.js
|
|
1615
|
+
var require_dist_cjs10 = __commonJS((exports, module) => {
|
|
1616
|
+
var __defProp = Object.defineProperty;
|
|
1617
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
1618
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
1619
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1620
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1621
|
+
var __export = (target, all) => {
|
|
1622
|
+
for (var name in all)
|
|
1623
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
1624
|
+
};
|
|
1625
|
+
var __copyProps = (to, from, except, desc) => {
|
|
1626
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
1627
|
+
for (let key of __getOwnPropNames(from))
|
|
1628
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
1629
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
1630
|
+
}
|
|
1631
|
+
return to;
|
|
1632
|
+
};
|
|
1633
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1634
|
+
var src_exports = {};
|
|
1635
|
+
__export(src_exports, {
|
|
1636
|
+
FetchHttpHandler: () => FetchHttpHandler,
|
|
1637
|
+
keepAliveSupport: () => keepAliveSupport,
|
|
1638
|
+
streamCollector: () => streamCollector
|
|
1639
|
+
});
|
|
1640
|
+
module.exports = __toCommonJS(src_exports);
|
|
1641
|
+
var import_protocol_http = require_dist_cjs2();
|
|
1642
|
+
var import_querystring_builder = require_dist_cjs4();
|
|
1643
|
+
function createRequest(url, requestOptions) {
|
|
1644
|
+
return new Request(url, requestOptions);
|
|
1645
|
+
}
|
|
1646
|
+
__name(createRequest, "createRequest");
|
|
1647
|
+
function requestTimeout(timeoutInMs = 0) {
|
|
1648
|
+
return new Promise((resolve, reject) => {
|
|
1649
|
+
if (timeoutInMs) {
|
|
1650
|
+
setTimeout(() => {
|
|
1651
|
+
const timeoutError = new Error(`Request did not complete within ${timeoutInMs} ms`);
|
|
1652
|
+
timeoutError.name = "TimeoutError";
|
|
1653
|
+
reject(timeoutError);
|
|
1654
|
+
}, timeoutInMs);
|
|
1655
|
+
}
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
__name(requestTimeout, "requestTimeout");
|
|
1659
|
+
var keepAliveSupport = {
|
|
1660
|
+
supported: undefined
|
|
1661
|
+
};
|
|
1662
|
+
var FetchHttpHandler = class _FetchHttpHandler {
|
|
1663
|
+
static {
|
|
1664
|
+
__name(this, "FetchHttpHandler");
|
|
1665
|
+
}
|
|
1666
|
+
static create(instanceOrOptions) {
|
|
1667
|
+
if (typeof instanceOrOptions?.handle === "function") {
|
|
1668
|
+
return instanceOrOptions;
|
|
1669
|
+
}
|
|
1670
|
+
return new _FetchHttpHandler(instanceOrOptions);
|
|
1671
|
+
}
|
|
1672
|
+
constructor(options) {
|
|
1673
|
+
if (typeof options === "function") {
|
|
1674
|
+
this.configProvider = options().then((opts) => opts || {});
|
|
1675
|
+
} else {
|
|
1676
|
+
this.config = options ?? {};
|
|
1677
|
+
this.configProvider = Promise.resolve(this.config);
|
|
1678
|
+
}
|
|
1679
|
+
if (keepAliveSupport.supported === undefined) {
|
|
1680
|
+
keepAliveSupport.supported = Boolean(typeof Request !== "undefined" && "keepalive" in createRequest("https://[::1]"));
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
destroy() {}
|
|
1684
|
+
async handle(request, { abortSignal } = {}) {
|
|
1685
|
+
if (!this.config) {
|
|
1686
|
+
this.config = await this.configProvider;
|
|
1687
|
+
}
|
|
1688
|
+
const requestTimeoutInMs = this.config.requestTimeout;
|
|
1689
|
+
const keepAlive = this.config.keepAlive === true;
|
|
1690
|
+
const credentials = this.config.credentials;
|
|
1691
|
+
if (abortSignal?.aborted) {
|
|
1692
|
+
const abortError = new Error("Request aborted");
|
|
1693
|
+
abortError.name = "AbortError";
|
|
1694
|
+
return Promise.reject(abortError);
|
|
1695
|
+
}
|
|
1696
|
+
let path = request.path;
|
|
1697
|
+
const queryString = (0, import_querystring_builder.buildQueryString)(request.query || {});
|
|
1698
|
+
if (queryString) {
|
|
1699
|
+
path += `?${queryString}`;
|
|
1700
|
+
}
|
|
1701
|
+
if (request.fragment) {
|
|
1702
|
+
path += `#${request.fragment}`;
|
|
1703
|
+
}
|
|
1704
|
+
let auth = "";
|
|
1705
|
+
if (request.username != null || request.password != null) {
|
|
1706
|
+
const username = request.username ?? "";
|
|
1707
|
+
const password = request.password ?? "";
|
|
1708
|
+
auth = `${username}:${password}@`;
|
|
1709
|
+
}
|
|
1710
|
+
const { port, method } = request;
|
|
1711
|
+
const url = `${request.protocol}//${auth}${request.hostname}${port ? `:${port}` : ""}${path}`;
|
|
1712
|
+
const body = method === "GET" || method === "HEAD" ? undefined : request.body;
|
|
1713
|
+
const requestOptions = {
|
|
1714
|
+
body,
|
|
1715
|
+
headers: new Headers(request.headers),
|
|
1716
|
+
method,
|
|
1717
|
+
credentials
|
|
1718
|
+
};
|
|
1719
|
+
if (this.config?.cache) {
|
|
1720
|
+
requestOptions.cache = this.config.cache;
|
|
1721
|
+
}
|
|
1722
|
+
if (body) {
|
|
1723
|
+
requestOptions.duplex = "half";
|
|
1724
|
+
}
|
|
1725
|
+
if (typeof AbortController !== "undefined") {
|
|
1726
|
+
requestOptions.signal = abortSignal;
|
|
1727
|
+
}
|
|
1728
|
+
if (keepAliveSupport.supported) {
|
|
1729
|
+
requestOptions.keepalive = keepAlive;
|
|
1730
|
+
}
|
|
1731
|
+
if (typeof this.config.requestInit === "function") {
|
|
1732
|
+
Object.assign(requestOptions, this.config.requestInit(request));
|
|
1733
|
+
}
|
|
1734
|
+
let removeSignalEventListener = /* @__PURE__ */ __name(() => {}, "removeSignalEventListener");
|
|
1735
|
+
const fetchRequest = createRequest(url, requestOptions);
|
|
1736
|
+
const raceOfPromises = [
|
|
1737
|
+
fetch(fetchRequest).then((response) => {
|
|
1738
|
+
const fetchHeaders = response.headers;
|
|
1739
|
+
const transformedHeaders = {};
|
|
1740
|
+
for (const pair of fetchHeaders.entries()) {
|
|
1741
|
+
transformedHeaders[pair[0]] = pair[1];
|
|
1742
|
+
}
|
|
1743
|
+
const hasReadableStream = response.body != null;
|
|
1744
|
+
if (!hasReadableStream) {
|
|
1745
|
+
return response.blob().then((body2) => ({
|
|
1746
|
+
response: new import_protocol_http.HttpResponse({
|
|
1747
|
+
headers: transformedHeaders,
|
|
1748
|
+
reason: response.statusText,
|
|
1749
|
+
statusCode: response.status,
|
|
1750
|
+
body: body2
|
|
1751
|
+
})
|
|
1752
|
+
}));
|
|
1753
|
+
}
|
|
1754
|
+
return {
|
|
1755
|
+
response: new import_protocol_http.HttpResponse({
|
|
1756
|
+
headers: transformedHeaders,
|
|
1757
|
+
reason: response.statusText,
|
|
1758
|
+
statusCode: response.status,
|
|
1759
|
+
body: response.body
|
|
1760
|
+
})
|
|
1761
|
+
};
|
|
1762
|
+
}),
|
|
1763
|
+
requestTimeout(requestTimeoutInMs)
|
|
1764
|
+
];
|
|
1765
|
+
if (abortSignal) {
|
|
1766
|
+
raceOfPromises.push(new Promise((resolve, reject) => {
|
|
1767
|
+
const onAbort = /* @__PURE__ */ __name(() => {
|
|
1768
|
+
const abortError = new Error("Request aborted");
|
|
1769
|
+
abortError.name = "AbortError";
|
|
1770
|
+
reject(abortError);
|
|
1771
|
+
}, "onAbort");
|
|
1772
|
+
if (typeof abortSignal.addEventListener === "function") {
|
|
1773
|
+
const signal = abortSignal;
|
|
1774
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
1775
|
+
removeSignalEventListener = /* @__PURE__ */ __name(() => signal.removeEventListener("abort", onAbort), "removeSignalEventListener");
|
|
1776
|
+
} else {
|
|
1777
|
+
abortSignal.onabort = onAbort;
|
|
1778
|
+
}
|
|
1779
|
+
}));
|
|
1780
|
+
}
|
|
1781
|
+
return Promise.race(raceOfPromises).finally(removeSignalEventListener);
|
|
1782
|
+
}
|
|
1783
|
+
updateHttpClientConfig(key, value) {
|
|
1784
|
+
this.config = undefined;
|
|
1785
|
+
this.configProvider = this.configProvider.then((config) => {
|
|
1786
|
+
config[key] = value;
|
|
1787
|
+
return config;
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
httpHandlerConfigs() {
|
|
1791
|
+
return this.config ?? {};
|
|
1792
|
+
}
|
|
1793
|
+
};
|
|
1794
|
+
var import_util_base64 = require_dist_cjs9();
|
|
1795
|
+
var streamCollector = /* @__PURE__ */ __name(async (stream) => {
|
|
1796
|
+
if (typeof Blob === "function" && stream instanceof Blob || stream.constructor?.name === "Blob") {
|
|
1797
|
+
if (Blob.prototype.arrayBuffer !== undefined) {
|
|
1798
|
+
return new Uint8Array(await stream.arrayBuffer());
|
|
1799
|
+
}
|
|
1800
|
+
return collectBlob(stream);
|
|
1801
|
+
}
|
|
1802
|
+
return collectStream(stream);
|
|
1803
|
+
}, "streamCollector");
|
|
1804
|
+
async function collectBlob(blob) {
|
|
1805
|
+
const base64 = await readToBase64(blob);
|
|
1806
|
+
const arrayBuffer = (0, import_util_base64.fromBase64)(base64);
|
|
1807
|
+
return new Uint8Array(arrayBuffer);
|
|
1808
|
+
}
|
|
1809
|
+
__name(collectBlob, "collectBlob");
|
|
1810
|
+
async function collectStream(stream) {
|
|
1811
|
+
const chunks = [];
|
|
1812
|
+
const reader = stream.getReader();
|
|
1813
|
+
let isDone = false;
|
|
1814
|
+
let length = 0;
|
|
1815
|
+
while (!isDone) {
|
|
1816
|
+
const { done, value } = await reader.read();
|
|
1817
|
+
if (value) {
|
|
1818
|
+
chunks.push(value);
|
|
1819
|
+
length += value.length;
|
|
1820
|
+
}
|
|
1821
|
+
isDone = done;
|
|
1822
|
+
}
|
|
1823
|
+
const collected = new Uint8Array(length);
|
|
1824
|
+
let offset = 0;
|
|
1825
|
+
for (const chunk of chunks) {
|
|
1826
|
+
collected.set(chunk, offset);
|
|
1827
|
+
offset += chunk.length;
|
|
1828
|
+
}
|
|
1829
|
+
return collected;
|
|
1830
|
+
}
|
|
1831
|
+
__name(collectStream, "collectStream");
|
|
1832
|
+
function readToBase64(blob) {
|
|
1833
|
+
return new Promise((resolve, reject) => {
|
|
1834
|
+
const reader = new FileReader;
|
|
1835
|
+
reader.onloadend = () => {
|
|
1836
|
+
if (reader.readyState !== 2) {
|
|
1837
|
+
return reject(new Error("Reader aborted too early"));
|
|
1838
|
+
}
|
|
1839
|
+
const result = reader.result ?? "";
|
|
1840
|
+
const commaIndex = result.indexOf(",");
|
|
1841
|
+
const dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length;
|
|
1842
|
+
resolve(result.substring(dataOffset));
|
|
1843
|
+
};
|
|
1844
|
+
reader.onabort = () => reject(new Error("Read aborted"));
|
|
1845
|
+
reader.onerror = () => reject(reader.error);
|
|
1846
|
+
reader.readAsDataURL(blob);
|
|
1847
|
+
});
|
|
1848
|
+
}
|
|
1849
|
+
__name(readToBase64, "readToBase64");
|
|
1850
|
+
});
|
|
1851
|
+
|
|
1852
|
+
// ../../../../node_modules/@smithy/util-hex-encoding/dist-cjs/index.js
|
|
1853
|
+
var require_dist_cjs11 = __commonJS((exports, module) => {
|
|
1854
|
+
var __defProp = Object.defineProperty;
|
|
1855
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
1856
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
1857
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1858
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1859
|
+
var __export = (target, all) => {
|
|
1860
|
+
for (var name in all)
|
|
1861
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
1862
|
+
};
|
|
1863
|
+
var __copyProps = (to, from, except, desc) => {
|
|
1864
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
1865
|
+
for (let key of __getOwnPropNames(from))
|
|
1866
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
1867
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
1868
|
+
}
|
|
1869
|
+
return to;
|
|
1870
|
+
};
|
|
1871
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1872
|
+
var src_exports = {};
|
|
1873
|
+
__export(src_exports, {
|
|
1874
|
+
fromHex: () => fromHex,
|
|
1875
|
+
toHex: () => toHex
|
|
1876
|
+
});
|
|
1877
|
+
module.exports = __toCommonJS(src_exports);
|
|
1878
|
+
var SHORT_TO_HEX = {};
|
|
1879
|
+
var HEX_TO_SHORT = {};
|
|
1880
|
+
for (let i = 0;i < 256; i++) {
|
|
1881
|
+
let encodedByte = i.toString(16).toLowerCase();
|
|
1882
|
+
if (encodedByte.length === 1) {
|
|
1883
|
+
encodedByte = `0${encodedByte}`;
|
|
1884
|
+
}
|
|
1885
|
+
SHORT_TO_HEX[i] = encodedByte;
|
|
1886
|
+
HEX_TO_SHORT[encodedByte] = i;
|
|
1887
|
+
}
|
|
1888
|
+
function fromHex(encoded) {
|
|
1889
|
+
if (encoded.length % 2 !== 0) {
|
|
1890
|
+
throw new Error("Hex encoded strings must have an even number length");
|
|
1891
|
+
}
|
|
1892
|
+
const out = new Uint8Array(encoded.length / 2);
|
|
1893
|
+
for (let i = 0;i < encoded.length; i += 2) {
|
|
1894
|
+
const encodedByte = encoded.slice(i, i + 2).toLowerCase();
|
|
1895
|
+
if (encodedByte in HEX_TO_SHORT) {
|
|
1896
|
+
out[i / 2] = HEX_TO_SHORT[encodedByte];
|
|
1897
|
+
} else {
|
|
1898
|
+
throw new Error(`Cannot decode unrecognized sequence ${encodedByte} as hexadecimal`);
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
return out;
|
|
1902
|
+
}
|
|
1903
|
+
__name(fromHex, "fromHex");
|
|
1904
|
+
function toHex(bytes) {
|
|
1905
|
+
let out = "";
|
|
1906
|
+
for (let i = 0;i < bytes.byteLength; i++) {
|
|
1907
|
+
out += SHORT_TO_HEX[bytes[i]];
|
|
1908
|
+
}
|
|
1909
|
+
return out;
|
|
1910
|
+
}
|
|
1911
|
+
__name(toHex, "toHex");
|
|
1912
|
+
});
|
|
1913
|
+
|
|
1914
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/sdk-stream-mixin.browser.js
|
|
1915
|
+
var require_sdk_stream_mixin_browser = __commonJS((exports) => {
|
|
1916
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1917
|
+
exports.sdkStreamMixin = undefined;
|
|
1918
|
+
var fetch_http_handler_1 = require_dist_cjs10();
|
|
1919
|
+
var util_base64_1 = require_dist_cjs9();
|
|
1920
|
+
var util_hex_encoding_1 = require_dist_cjs11();
|
|
1921
|
+
var util_utf8_1 = require_dist_cjs8();
|
|
1922
|
+
var stream_type_check_1 = require_stream_type_check();
|
|
1923
|
+
var ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED = "The stream has already been transformed.";
|
|
1924
|
+
var sdkStreamMixin2 = (stream) => {
|
|
1925
|
+
var _a, _b;
|
|
1926
|
+
if (!isBlobInstance(stream) && !(0, stream_type_check_1.isReadableStream)(stream)) {
|
|
1927
|
+
const name = ((_b = (_a = stream === null || stream === undefined ? undefined : stream.__proto__) === null || _a === undefined ? undefined : _a.constructor) === null || _b === undefined ? undefined : _b.name) || stream;
|
|
1928
|
+
throw new Error(`Unexpected stream implementation, expect Blob or ReadableStream, got ${name}`);
|
|
1929
|
+
}
|
|
1930
|
+
let transformed = false;
|
|
1931
|
+
const transformToByteArray = async () => {
|
|
1932
|
+
if (transformed) {
|
|
1933
|
+
throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED);
|
|
1934
|
+
}
|
|
1935
|
+
transformed = true;
|
|
1936
|
+
return await (0, fetch_http_handler_1.streamCollector)(stream);
|
|
1937
|
+
};
|
|
1938
|
+
const blobToWebStream = (blob) => {
|
|
1939
|
+
if (typeof blob.stream !== "function") {
|
|
1940
|
+
throw new Error(`Cannot transform payload Blob to web stream. Please make sure the Blob.stream() is polyfilled.
|
|
1941
|
+
` + "If you are using React Native, this API is not yet supported, see: https://react-native.canny.io/feature-requests/p/fetch-streaming-body");
|
|
1942
|
+
}
|
|
1943
|
+
return blob.stream();
|
|
1944
|
+
};
|
|
1945
|
+
return Object.assign(stream, {
|
|
1946
|
+
transformToByteArray,
|
|
1947
|
+
transformToString: async (encoding) => {
|
|
1948
|
+
const buf = await transformToByteArray();
|
|
1949
|
+
if (encoding === "base64") {
|
|
1950
|
+
return (0, util_base64_1.toBase64)(buf);
|
|
1951
|
+
} else if (encoding === "hex") {
|
|
1952
|
+
return (0, util_hex_encoding_1.toHex)(buf);
|
|
1953
|
+
} else if (encoding === undefined || encoding === "utf8" || encoding === "utf-8") {
|
|
1954
|
+
return (0, util_utf8_1.toUtf8)(buf);
|
|
1955
|
+
} else if (typeof TextDecoder === "function") {
|
|
1956
|
+
return new TextDecoder(encoding).decode(buf);
|
|
1957
|
+
} else {
|
|
1958
|
+
throw new Error("TextDecoder is not available, please make sure polyfill is provided.");
|
|
1959
|
+
}
|
|
1960
|
+
},
|
|
1961
|
+
transformToWebStream: () => {
|
|
1962
|
+
if (transformed) {
|
|
1963
|
+
throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED);
|
|
1964
|
+
}
|
|
1965
|
+
transformed = true;
|
|
1966
|
+
if (isBlobInstance(stream)) {
|
|
1967
|
+
return blobToWebStream(stream);
|
|
1968
|
+
} else if ((0, stream_type_check_1.isReadableStream)(stream)) {
|
|
1969
|
+
return stream;
|
|
1970
|
+
} else {
|
|
1971
|
+
throw new Error(`Cannot transform payload to web stream, got ${stream}`);
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
});
|
|
1975
|
+
};
|
|
1976
|
+
exports.sdkStreamMixin = sdkStreamMixin2;
|
|
1977
|
+
var isBlobInstance = (stream) => typeof Blob === "function" && stream instanceof Blob;
|
|
1978
|
+
});
|
|
1979
|
+
|
|
1980
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/sdk-stream-mixin.js
|
|
1981
|
+
var require_sdk_stream_mixin = __commonJS((exports) => {
|
|
1982
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1983
|
+
exports.sdkStreamMixin = undefined;
|
|
1984
|
+
var node_http_handler_1 = require_dist_cjs5();
|
|
1985
|
+
var util_buffer_from_1 = require_dist_cjs7();
|
|
1986
|
+
var stream_1 = __require("node:stream");
|
|
1987
|
+
var sdk_stream_mixin_browser_1 = require_sdk_stream_mixin_browser();
|
|
1988
|
+
var ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED = "The stream has already been transformed.";
|
|
1989
|
+
var sdkStreamMixin2 = (stream) => {
|
|
1990
|
+
var _a, _b;
|
|
1991
|
+
if (!(stream instanceof stream_1.Readable)) {
|
|
1992
|
+
try {
|
|
1993
|
+
return (0, sdk_stream_mixin_browser_1.sdkStreamMixin)(stream);
|
|
1994
|
+
} catch (e) {
|
|
1995
|
+
const name = ((_b = (_a = stream === null || stream === undefined ? undefined : stream.__proto__) === null || _a === undefined ? undefined : _a.constructor) === null || _b === undefined ? undefined : _b.name) || stream;
|
|
1996
|
+
throw new Error(`Unexpected stream implementation, expect Stream.Readable instance, got ${name}`);
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
let transformed = false;
|
|
2000
|
+
const transformToByteArray = async () => {
|
|
2001
|
+
if (transformed) {
|
|
2002
|
+
throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED);
|
|
2003
|
+
}
|
|
2004
|
+
transformed = true;
|
|
2005
|
+
return await (0, node_http_handler_1.streamCollector)(stream);
|
|
2006
|
+
};
|
|
2007
|
+
return Object.assign(stream, {
|
|
2008
|
+
transformToByteArray,
|
|
2009
|
+
transformToString: async (encoding) => {
|
|
2010
|
+
const buf = await transformToByteArray();
|
|
2011
|
+
if (encoding === undefined || Buffer.isEncoding(encoding)) {
|
|
2012
|
+
return (0, util_buffer_from_1.fromArrayBuffer)(buf.buffer, buf.byteOffset, buf.byteLength).toString(encoding);
|
|
2013
|
+
} else {
|
|
2014
|
+
const decoder = new TextDecoder(encoding);
|
|
2015
|
+
return decoder.decode(buf);
|
|
2016
|
+
}
|
|
2017
|
+
},
|
|
2018
|
+
transformToWebStream: () => {
|
|
2019
|
+
if (transformed) {
|
|
2020
|
+
throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED);
|
|
2021
|
+
}
|
|
2022
|
+
if (stream.readableFlowing !== null) {
|
|
2023
|
+
throw new Error("The stream has been consumed by other callbacks.");
|
|
2024
|
+
}
|
|
2025
|
+
if (typeof stream_1.Readable.toWeb !== "function") {
|
|
2026
|
+
throw new Error("Readable.toWeb() is not supported. Please ensure a polyfill is available.");
|
|
2027
|
+
}
|
|
2028
|
+
transformed = true;
|
|
2029
|
+
return stream_1.Readable.toWeb(stream);
|
|
2030
|
+
}
|
|
2031
|
+
});
|
|
2032
|
+
};
|
|
2033
|
+
exports.sdkStreamMixin = sdkStreamMixin2;
|
|
2034
|
+
});
|
|
2035
|
+
|
|
2036
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/splitStream.browser.js
|
|
2037
|
+
var require_splitStream_browser = __commonJS((exports) => {
|
|
2038
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2039
|
+
exports.splitStream = undefined;
|
|
2040
|
+
async function splitStream2(stream) {
|
|
2041
|
+
if (typeof stream.stream === "function") {
|
|
2042
|
+
stream = stream.stream();
|
|
2043
|
+
}
|
|
2044
|
+
const readableStream = stream;
|
|
2045
|
+
return readableStream.tee();
|
|
2046
|
+
}
|
|
2047
|
+
exports.splitStream = splitStream2;
|
|
2048
|
+
});
|
|
2049
|
+
|
|
2050
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/splitStream.js
|
|
2051
|
+
var require_splitStream = __commonJS((exports) => {
|
|
2052
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2053
|
+
exports.splitStream = undefined;
|
|
2054
|
+
var stream_1 = __require("node:stream");
|
|
2055
|
+
var splitStream_browser_1 = require_splitStream_browser();
|
|
2056
|
+
var stream_type_check_1 = require_stream_type_check();
|
|
2057
|
+
async function splitStream2(stream) {
|
|
2058
|
+
if ((0, stream_type_check_1.isReadableStream)(stream) || (0, stream_type_check_1.isBlob)(stream)) {
|
|
2059
|
+
return (0, splitStream_browser_1.splitStream)(stream);
|
|
2060
|
+
}
|
|
2061
|
+
const stream1 = new stream_1.PassThrough;
|
|
2062
|
+
const stream2 = new stream_1.PassThrough;
|
|
2063
|
+
stream.pipe(stream1);
|
|
2064
|
+
stream.pipe(stream2);
|
|
2065
|
+
return [stream1, stream2];
|
|
2066
|
+
}
|
|
2067
|
+
exports.splitStream = splitStream2;
|
|
2068
|
+
});
|
|
2069
|
+
|
|
2070
|
+
// ../../../../node_modules/@smithy/util-stream/dist-cjs/index.js
|
|
2071
|
+
var require_dist_cjs12 = __commonJS((exports, module) => {
|
|
2072
|
+
var __defProp = Object.defineProperty;
|
|
2073
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
2074
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2075
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2076
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
2077
|
+
var __export = (target, all) => {
|
|
2078
|
+
for (var name in all)
|
|
2079
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
2080
|
+
};
|
|
2081
|
+
var __copyProps = (to, from, except, desc) => {
|
|
2082
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
2083
|
+
for (let key of __getOwnPropNames(from))
|
|
2084
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
2085
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
2086
|
+
}
|
|
2087
|
+
return to;
|
|
2088
|
+
};
|
|
2089
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
2090
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2091
|
+
var src_exports = {};
|
|
2092
|
+
__export(src_exports, {
|
|
2093
|
+
Uint8ArrayBlobAdapter: () => Uint8ArrayBlobAdapter
|
|
2094
|
+
});
|
|
2095
|
+
module.exports = __toCommonJS(src_exports);
|
|
2096
|
+
var import_util_base64 = require_dist_cjs9();
|
|
2097
|
+
var import_util_utf8 = require_dist_cjs8();
|
|
2098
|
+
function transformToString(payload, encoding = "utf-8") {
|
|
2099
|
+
if (encoding === "base64") {
|
|
2100
|
+
return (0, import_util_base64.toBase64)(payload);
|
|
2101
|
+
}
|
|
2102
|
+
return (0, import_util_utf8.toUtf8)(payload);
|
|
2103
|
+
}
|
|
2104
|
+
__name(transformToString, "transformToString");
|
|
2105
|
+
function transformFromString(str, encoding) {
|
|
2106
|
+
if (encoding === "base64") {
|
|
2107
|
+
return Uint8ArrayBlobAdapter.mutate((0, import_util_base64.fromBase64)(str));
|
|
2108
|
+
}
|
|
2109
|
+
return Uint8ArrayBlobAdapter.mutate((0, import_util_utf8.fromUtf8)(str));
|
|
2110
|
+
}
|
|
2111
|
+
__name(transformFromString, "transformFromString");
|
|
2112
|
+
var Uint8ArrayBlobAdapter = class _Uint8ArrayBlobAdapter extends Uint8Array {
|
|
2113
|
+
static {
|
|
2114
|
+
__name(this, "Uint8ArrayBlobAdapter");
|
|
2115
|
+
}
|
|
2116
|
+
static fromString(source, encoding = "utf-8") {
|
|
2117
|
+
switch (typeof source) {
|
|
2118
|
+
case "string":
|
|
2119
|
+
return transformFromString(source, encoding);
|
|
2120
|
+
default:
|
|
2121
|
+
throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`);
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
static mutate(source) {
|
|
2125
|
+
Object.setPrototypeOf(source, _Uint8ArrayBlobAdapter.prototype);
|
|
2126
|
+
return source;
|
|
2127
|
+
}
|
|
2128
|
+
transformToString(encoding = "utf-8") {
|
|
2129
|
+
return transformToString(this, encoding);
|
|
2130
|
+
}
|
|
2131
|
+
};
|
|
2132
|
+
__reExport(src_exports, require_ChecksumStream(), module.exports);
|
|
2133
|
+
__reExport(src_exports, require_createChecksumStream(), module.exports);
|
|
2134
|
+
__reExport(src_exports, require_createBufferedReadable(), module.exports);
|
|
2135
|
+
__reExport(src_exports, require_getAwsChunkedEncodingStream(), module.exports);
|
|
2136
|
+
__reExport(src_exports, require_headStream(), module.exports);
|
|
2137
|
+
__reExport(src_exports, require_sdk_stream_mixin(), module.exports);
|
|
2138
|
+
__reExport(src_exports, require_splitStream(), module.exports);
|
|
2139
|
+
__reExport(src_exports, require_stream_type_check(), module.exports);
|
|
2140
|
+
});
|
|
2141
|
+
|
|
2142
|
+
// ../../../../node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js
|
|
2143
|
+
var require_protocols = __commonJS((exports, module) => {
|
|
2144
|
+
var __defProp = Object.defineProperty;
|
|
2145
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
2146
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2147
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2148
|
+
var __export = (target, all) => {
|
|
2149
|
+
for (var name in all)
|
|
2150
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
2151
|
+
};
|
|
2152
|
+
var __copyProps = (to, from, except, desc) => {
|
|
2153
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
2154
|
+
for (let key of __getOwnPropNames(from))
|
|
2155
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
2156
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
2157
|
+
}
|
|
2158
|
+
return to;
|
|
2159
|
+
};
|
|
2160
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2161
|
+
var protocols_exports = {};
|
|
2162
|
+
__export(protocols_exports, {
|
|
2163
|
+
RequestBuilder: () => RequestBuilder,
|
|
2164
|
+
collectBody: () => collectBody,
|
|
2165
|
+
extendedEncodeURIComponent: () => extendedEncodeURIComponent,
|
|
2166
|
+
requestBuilder: () => requestBuilder,
|
|
2167
|
+
resolvedPath: () => resolvedPath
|
|
2168
|
+
});
|
|
2169
|
+
module.exports = __toCommonJS(protocols_exports);
|
|
2170
|
+
var import_util_stream = require_dist_cjs12();
|
|
2171
|
+
var collectBody = async (streamBody = new Uint8Array, context) => {
|
|
2172
|
+
if (streamBody instanceof Uint8Array) {
|
|
2173
|
+
return import_util_stream.Uint8ArrayBlobAdapter.mutate(streamBody);
|
|
2174
|
+
}
|
|
2175
|
+
if (!streamBody) {
|
|
2176
|
+
return import_util_stream.Uint8ArrayBlobAdapter.mutate(new Uint8Array);
|
|
2177
|
+
}
|
|
2178
|
+
const fromContext = context.streamCollector(streamBody);
|
|
2179
|
+
return import_util_stream.Uint8ArrayBlobAdapter.mutate(await fromContext);
|
|
2180
|
+
};
|
|
2181
|
+
function extendedEncodeURIComponent(str) {
|
|
2182
|
+
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
|
|
2183
|
+
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
|
|
2184
|
+
});
|
|
2185
|
+
}
|
|
2186
|
+
var import_protocol_http = require_dist_cjs2();
|
|
2187
|
+
var resolvedPath = (resolvedPath2, input, memberName, labelValueProvider, uriLabel, isGreedyLabel) => {
|
|
2188
|
+
if (input != null && input[memberName] !== undefined) {
|
|
2189
|
+
const labelValue = labelValueProvider();
|
|
2190
|
+
if (labelValue.length <= 0) {
|
|
2191
|
+
throw new Error("Empty value provided for input HTTP label: " + memberName + ".");
|
|
2192
|
+
}
|
|
2193
|
+
resolvedPath2 = resolvedPath2.replace(uriLabel, isGreedyLabel ? labelValue.split("/").map((segment) => extendedEncodeURIComponent(segment)).join("/") : extendedEncodeURIComponent(labelValue));
|
|
2194
|
+
} else {
|
|
2195
|
+
throw new Error("No value provided for input HTTP label: " + memberName + ".");
|
|
2196
|
+
}
|
|
2197
|
+
return resolvedPath2;
|
|
2198
|
+
};
|
|
2199
|
+
function requestBuilder(input, context) {
|
|
2200
|
+
return new RequestBuilder(input, context);
|
|
2201
|
+
}
|
|
2202
|
+
var RequestBuilder = class {
|
|
2203
|
+
constructor(input, context) {
|
|
2204
|
+
this.input = input;
|
|
2205
|
+
this.context = context;
|
|
2206
|
+
this.query = {};
|
|
2207
|
+
this.method = "";
|
|
2208
|
+
this.headers = {};
|
|
2209
|
+
this.path = "";
|
|
2210
|
+
this.body = null;
|
|
2211
|
+
this.hostname = "";
|
|
2212
|
+
this.resolvePathStack = [];
|
|
2213
|
+
}
|
|
2214
|
+
async build() {
|
|
2215
|
+
const { hostname, protocol = "https", port, path: basePath } = await this.context.endpoint();
|
|
2216
|
+
this.path = basePath;
|
|
2217
|
+
for (const resolvePath of this.resolvePathStack) {
|
|
2218
|
+
resolvePath(this.path);
|
|
2219
|
+
}
|
|
2220
|
+
return new import_protocol_http.HttpRequest({
|
|
2221
|
+
protocol,
|
|
2222
|
+
hostname: this.hostname || hostname,
|
|
2223
|
+
port,
|
|
2224
|
+
method: this.method,
|
|
2225
|
+
path: this.path,
|
|
2226
|
+
query: this.query,
|
|
2227
|
+
body: this.body,
|
|
2228
|
+
headers: this.headers
|
|
2229
|
+
});
|
|
2230
|
+
}
|
|
2231
|
+
hn(hostname) {
|
|
2232
|
+
this.hostname = hostname;
|
|
2233
|
+
return this;
|
|
2234
|
+
}
|
|
2235
|
+
bp(uriLabel) {
|
|
2236
|
+
this.resolvePathStack.push((basePath) => {
|
|
2237
|
+
this.path = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + uriLabel;
|
|
2238
|
+
});
|
|
2239
|
+
return this;
|
|
2240
|
+
}
|
|
2241
|
+
p(memberName, labelValueProvider, uriLabel, isGreedyLabel) {
|
|
2242
|
+
this.resolvePathStack.push((path) => {
|
|
2243
|
+
this.path = resolvedPath(path, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
|
|
2244
|
+
});
|
|
2245
|
+
return this;
|
|
2246
|
+
}
|
|
2247
|
+
h(headers) {
|
|
2248
|
+
this.headers = headers;
|
|
2249
|
+
return this;
|
|
2250
|
+
}
|
|
2251
|
+
q(query) {
|
|
2252
|
+
this.query = query;
|
|
2253
|
+
return this;
|
|
2254
|
+
}
|
|
2255
|
+
b(body) {
|
|
2256
|
+
this.body = body;
|
|
2257
|
+
return this;
|
|
2258
|
+
}
|
|
2259
|
+
m(method) {
|
|
2260
|
+
this.method = method;
|
|
2261
|
+
return this;
|
|
2262
|
+
}
|
|
2263
|
+
};
|
|
2264
|
+
});
|
|
2265
|
+
|
|
2266
|
+
export { require_dist_cjs2 as require_dist_cjs, require_dist_cjs6 as require_dist_cjs1, require_dist_cjs7 as require_dist_cjs2, require_dist_cjs8 as require_dist_cjs3, require_dist_cjs9 as require_dist_cjs4, require_dist_cjs3 as require_dist_cjs5, require_dist_cjs5 as require_dist_cjs6, require_dist_cjs11 as require_dist_cjs7, require_dist_cjs12 as require_dist_cjs8, require_protocols };
|