replicas-engine 0.1.141 → 0.1.143
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/src/chunk-5V5ZNFZK.js +178 -0
- package/dist/src/chunk-7RS3TOFT.js +5862 -0
- package/dist/src/chunk-ERL3EC7G.js +44 -0
- package/dist/src/chunk-J3WZZOOL.js +1316 -0
- package/dist/src/chunk-JFXVYYQY.js +242 -0
- package/dist/src/chunk-MCYTXPBZ.js +29 -0
- package/dist/src/chunk-N2BGF5AZ.js +14 -0
- package/dist/src/chunk-NPXMDMPW.js +175 -0
- package/dist/src/chunk-TY2FR253.js +590 -0
- package/dist/src/chunk-WCAERHFE.js +62 -0
- package/dist/src/chunk-XCFRYWEV.js +164 -0
- package/dist/src/chunk-YDW6RZI2.js +39 -0
- package/dist/src/chunk-ZDZBYCXV.js +52 -0
- package/dist/src/dist-es-3LYC7DO3.js +169 -0
- package/dist/src/dist-es-7DTYZ3KD.js +489 -0
- package/dist/src/dist-es-BNJQGHZR.js +88 -0
- package/dist/src/dist-es-EVINFDC2.js +46 -0
- package/dist/src/dist-es-KHBICPEM.js +380 -0
- package/dist/src/dist-es-UV765YRF.js +324 -0
- package/dist/src/dist-es-YWO2URNL.js +70 -0
- package/dist/src/event-streams-IFAW3KBX.js +244 -0
- package/dist/src/event-streams-XS4D2DFO.js +252 -0
- package/dist/src/index.js +12 -4
- package/dist/src/loadSso-ZRFAKENS.js +590 -0
- package/dist/src/signin-PNR24U2H.js +702 -0
- package/dist/src/sso-oidc-O55BGCVQ.js +827 -0
- package/dist/src/sts-MRC7OH6Z.js +3876 -0
- package/package.json +1 -1
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
fromArrayBuffer,
|
|
4
|
+
fromString,
|
|
5
|
+
fromUtf8
|
|
6
|
+
} from "./chunk-ERL3EC7G.js";
|
|
7
|
+
|
|
8
|
+
// ../node_modules/.bun/@smithy+protocol-http@5.3.12/node_modules/@smithy/protocol-http/dist-es/httpResponse.js
|
|
9
|
+
var HttpResponse = class {
|
|
10
|
+
statusCode;
|
|
11
|
+
reason;
|
|
12
|
+
headers;
|
|
13
|
+
body;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
this.statusCode = options.statusCode;
|
|
16
|
+
this.reason = options.reason;
|
|
17
|
+
this.headers = options.headers || {};
|
|
18
|
+
this.body = options.body;
|
|
19
|
+
}
|
|
20
|
+
static isInstance(response) {
|
|
21
|
+
if (!response)
|
|
22
|
+
return false;
|
|
23
|
+
const resp = response;
|
|
24
|
+
return typeof resp.statusCode === "number" && typeof resp.headers === "object";
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// ../node_modules/.bun/@smithy+util-uri-escape@4.2.2/node_modules/@smithy/util-uri-escape/dist-es/escape-uri.js
|
|
29
|
+
var escapeUri = (uri) => encodeURIComponent(uri).replace(/[!'()*]/g, hexEncode);
|
|
30
|
+
var hexEncode = (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`;
|
|
31
|
+
|
|
32
|
+
// ../node_modules/.bun/@smithy+querystring-builder@4.2.12/node_modules/@smithy/querystring-builder/dist-es/index.js
|
|
33
|
+
function buildQueryString(query) {
|
|
34
|
+
const parts = [];
|
|
35
|
+
for (let key of Object.keys(query).sort()) {
|
|
36
|
+
const value = query[key];
|
|
37
|
+
key = escapeUri(key);
|
|
38
|
+
if (Array.isArray(value)) {
|
|
39
|
+
for (let i = 0, iLen = value.length; i < iLen; i++) {
|
|
40
|
+
parts.push(`${key}=${escapeUri(value[i])}`);
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
let qsEntry = key;
|
|
44
|
+
if (value || typeof value === "string") {
|
|
45
|
+
qsEntry += `=${escapeUri(value)}`;
|
|
46
|
+
}
|
|
47
|
+
parts.push(qsEntry);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return parts.join("&");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ../node_modules/.bun/@smithy+node-http-handler@4.5.1/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
|
|
54
|
+
import { Agent as hsAgent, request as hsRequest } from "https";
|
|
55
|
+
|
|
56
|
+
// ../node_modules/.bun/@smithy+node-http-handler@4.5.1/node_modules/@smithy/node-http-handler/dist-es/build-abort-error.js
|
|
57
|
+
function buildAbortError(abortSignal) {
|
|
58
|
+
const reason = abortSignal && typeof abortSignal === "object" && "reason" in abortSignal ? abortSignal.reason : void 0;
|
|
59
|
+
if (reason) {
|
|
60
|
+
if (reason instanceof Error) {
|
|
61
|
+
const abortError3 = new Error("Request aborted");
|
|
62
|
+
abortError3.name = "AbortError";
|
|
63
|
+
abortError3.cause = reason;
|
|
64
|
+
return abortError3;
|
|
65
|
+
}
|
|
66
|
+
const abortError2 = new Error(String(reason));
|
|
67
|
+
abortError2.name = "AbortError";
|
|
68
|
+
return abortError2;
|
|
69
|
+
}
|
|
70
|
+
const abortError = new Error("Request aborted");
|
|
71
|
+
abortError.name = "AbortError";
|
|
72
|
+
return abortError;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ../node_modules/.bun/@smithy+node-http-handler@4.5.1/node_modules/@smithy/node-http-handler/dist-es/constants.js
|
|
76
|
+
var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
|
|
77
|
+
|
|
78
|
+
// ../node_modules/.bun/@smithy+node-http-handler@4.5.1/node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js
|
|
79
|
+
var getTransformedHeaders = (headers) => {
|
|
80
|
+
const transformedHeaders = {};
|
|
81
|
+
for (const name of Object.keys(headers)) {
|
|
82
|
+
const headerValues = headers[name];
|
|
83
|
+
transformedHeaders[name] = Array.isArray(headerValues) ? headerValues.join(",") : headerValues;
|
|
84
|
+
}
|
|
85
|
+
return transformedHeaders;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// ../node_modules/.bun/@smithy+node-http-handler@4.5.1/node_modules/@smithy/node-http-handler/dist-es/timing.js
|
|
89
|
+
var timing = {
|
|
90
|
+
setTimeout: (cb, ms) => setTimeout(cb, ms),
|
|
91
|
+
clearTimeout: (timeoutId) => clearTimeout(timeoutId)
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// ../node_modules/.bun/@smithy+node-http-handler@4.5.1/node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js
|
|
95
|
+
var DEFER_EVENT_LISTENER_TIME = 1e3;
|
|
96
|
+
var setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
|
|
97
|
+
if (!timeoutInMs) {
|
|
98
|
+
return -1;
|
|
99
|
+
}
|
|
100
|
+
const registerTimeout = (offset) => {
|
|
101
|
+
const timeoutId = timing.setTimeout(() => {
|
|
102
|
+
request.destroy();
|
|
103
|
+
reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${timeoutInMs} ms.`), {
|
|
104
|
+
name: "TimeoutError"
|
|
105
|
+
}));
|
|
106
|
+
}, timeoutInMs - offset);
|
|
107
|
+
const doWithSocket = (socket) => {
|
|
108
|
+
if (socket?.connecting) {
|
|
109
|
+
socket.on("connect", () => {
|
|
110
|
+
timing.clearTimeout(timeoutId);
|
|
111
|
+
});
|
|
112
|
+
} else {
|
|
113
|
+
timing.clearTimeout(timeoutId);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
if (request.socket) {
|
|
117
|
+
doWithSocket(request.socket);
|
|
118
|
+
} else {
|
|
119
|
+
request.on("socket", doWithSocket);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
if (timeoutInMs < 2e3) {
|
|
123
|
+
registerTimeout(0);
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// ../node_modules/.bun/@smithy+node-http-handler@4.5.1/node_modules/@smithy/node-http-handler/dist-es/set-request-timeout.js
|
|
130
|
+
var setRequestTimeout = (req, reject, timeoutInMs = 0, throwOnRequestTimeout, logger) => {
|
|
131
|
+
if (timeoutInMs) {
|
|
132
|
+
return timing.setTimeout(() => {
|
|
133
|
+
let msg = `@smithy/node-http-handler - [${throwOnRequestTimeout ? "ERROR" : "WARN"}] a request has exceeded the configured ${timeoutInMs} ms requestTimeout.`;
|
|
134
|
+
if (throwOnRequestTimeout) {
|
|
135
|
+
const error = Object.assign(new Error(msg), {
|
|
136
|
+
name: "TimeoutError",
|
|
137
|
+
code: "ETIMEDOUT"
|
|
138
|
+
});
|
|
139
|
+
req.destroy(error);
|
|
140
|
+
reject(error);
|
|
141
|
+
} else {
|
|
142
|
+
msg += ` Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.`;
|
|
143
|
+
logger?.warn?.(msg);
|
|
144
|
+
}
|
|
145
|
+
}, timeoutInMs);
|
|
146
|
+
}
|
|
147
|
+
return -1;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// ../node_modules/.bun/@smithy+node-http-handler@4.5.1/node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js
|
|
151
|
+
var DEFER_EVENT_LISTENER_TIME2 = 3e3;
|
|
152
|
+
var setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME2) => {
|
|
153
|
+
if (keepAlive !== true) {
|
|
154
|
+
return -1;
|
|
155
|
+
}
|
|
156
|
+
const registerListener = () => {
|
|
157
|
+
if (request.socket) {
|
|
158
|
+
request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
159
|
+
} else {
|
|
160
|
+
request.on("socket", (socket) => {
|
|
161
|
+
socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
if (deferTimeMs === 0) {
|
|
166
|
+
registerListener();
|
|
167
|
+
return 0;
|
|
168
|
+
}
|
|
169
|
+
return timing.setTimeout(registerListener, deferTimeMs);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// ../node_modules/.bun/@smithy+node-http-handler@4.5.1/node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js
|
|
173
|
+
var DEFER_EVENT_LISTENER_TIME3 = 3e3;
|
|
174
|
+
var setSocketTimeout = (request, reject, timeoutInMs = 0) => {
|
|
175
|
+
const registerTimeout = (offset) => {
|
|
176
|
+
const timeout = timeoutInMs - offset;
|
|
177
|
+
const onTimeout = () => {
|
|
178
|
+
request.destroy();
|
|
179
|
+
reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${timeoutInMs} ms of inactivity (configured by client requestHandler).`), { name: "TimeoutError" }));
|
|
180
|
+
};
|
|
181
|
+
if (request.socket) {
|
|
182
|
+
request.socket.setTimeout(timeout, onTimeout);
|
|
183
|
+
request.on("close", () => request.socket?.removeListener("timeout", onTimeout));
|
|
184
|
+
} else {
|
|
185
|
+
request.setTimeout(timeout, onTimeout);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
if (0 < timeoutInMs && timeoutInMs < 6e3) {
|
|
189
|
+
registerTimeout(0);
|
|
190
|
+
return 0;
|
|
191
|
+
}
|
|
192
|
+
return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME3), DEFER_EVENT_LISTENER_TIME3);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// ../node_modules/.bun/@smithy+node-http-handler@4.5.1/node_modules/@smithy/node-http-handler/dist-es/write-request-body.js
|
|
196
|
+
import { Readable } from "stream";
|
|
197
|
+
var MIN_WAIT_TIME = 6e3;
|
|
198
|
+
async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME, externalAgent = false) {
|
|
199
|
+
const headers = request.headers ?? {};
|
|
200
|
+
const expect = headers.Expect || headers.expect;
|
|
201
|
+
let timeoutId = -1;
|
|
202
|
+
let sendBody = true;
|
|
203
|
+
if (!externalAgent && expect === "100-continue") {
|
|
204
|
+
sendBody = await Promise.race([
|
|
205
|
+
new Promise((resolve) => {
|
|
206
|
+
timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
207
|
+
}),
|
|
208
|
+
new Promise((resolve) => {
|
|
209
|
+
httpRequest.on("continue", () => {
|
|
210
|
+
timing.clearTimeout(timeoutId);
|
|
211
|
+
resolve(true);
|
|
212
|
+
});
|
|
213
|
+
httpRequest.on("response", () => {
|
|
214
|
+
timing.clearTimeout(timeoutId);
|
|
215
|
+
resolve(false);
|
|
216
|
+
});
|
|
217
|
+
httpRequest.on("error", () => {
|
|
218
|
+
timing.clearTimeout(timeoutId);
|
|
219
|
+
resolve(false);
|
|
220
|
+
});
|
|
221
|
+
})
|
|
222
|
+
]);
|
|
223
|
+
}
|
|
224
|
+
if (sendBody) {
|
|
225
|
+
writeBody(httpRequest, request.body);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function writeBody(httpRequest, body) {
|
|
229
|
+
if (body instanceof Readable) {
|
|
230
|
+
body.pipe(httpRequest);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (body) {
|
|
234
|
+
const isBuffer = Buffer.isBuffer(body);
|
|
235
|
+
const isString = typeof body === "string";
|
|
236
|
+
if (isBuffer || isString) {
|
|
237
|
+
if (isBuffer && body.byteLength === 0) {
|
|
238
|
+
httpRequest.end();
|
|
239
|
+
} else {
|
|
240
|
+
httpRequest.end(body);
|
|
241
|
+
}
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const uint8 = body;
|
|
245
|
+
if (typeof uint8 === "object" && uint8.buffer && typeof uint8.byteOffset === "number" && typeof uint8.byteLength === "number") {
|
|
246
|
+
httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
httpRequest.end(Buffer.from(body));
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
httpRequest.end();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// ../node_modules/.bun/@smithy+node-http-handler@4.5.1/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
|
|
256
|
+
var hAgent = void 0;
|
|
257
|
+
var hRequest = void 0;
|
|
258
|
+
var NodeHttpHandler = class _NodeHttpHandler {
|
|
259
|
+
config;
|
|
260
|
+
configProvider;
|
|
261
|
+
socketWarningTimestamp = 0;
|
|
262
|
+
externalAgent = false;
|
|
263
|
+
metadata = { handlerProtocol: "http/1.1" };
|
|
264
|
+
static create(instanceOrOptions) {
|
|
265
|
+
if (typeof instanceOrOptions?.handle === "function") {
|
|
266
|
+
return instanceOrOptions;
|
|
267
|
+
}
|
|
268
|
+
return new _NodeHttpHandler(instanceOrOptions);
|
|
269
|
+
}
|
|
270
|
+
static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
|
|
271
|
+
const { sockets, requests, maxSockets } = agent;
|
|
272
|
+
if (typeof maxSockets !== "number" || maxSockets === Infinity) {
|
|
273
|
+
return socketWarningTimestamp;
|
|
274
|
+
}
|
|
275
|
+
const interval = 15e3;
|
|
276
|
+
if (Date.now() - interval < socketWarningTimestamp) {
|
|
277
|
+
return socketWarningTimestamp;
|
|
278
|
+
}
|
|
279
|
+
if (sockets && requests) {
|
|
280
|
+
for (const origin in sockets) {
|
|
281
|
+
const socketsInUse = sockets[origin]?.length ?? 0;
|
|
282
|
+
const requestsEnqueued = requests[origin]?.length ?? 0;
|
|
283
|
+
if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
|
|
284
|
+
logger?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
|
|
285
|
+
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
|
|
286
|
+
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
|
|
287
|
+
return Date.now();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return socketWarningTimestamp;
|
|
292
|
+
}
|
|
293
|
+
constructor(options) {
|
|
294
|
+
this.configProvider = new Promise((resolve, reject) => {
|
|
295
|
+
if (typeof options === "function") {
|
|
296
|
+
options().then((_options) => {
|
|
297
|
+
resolve(this.resolveDefaultConfig(_options));
|
|
298
|
+
}).catch(reject);
|
|
299
|
+
} else {
|
|
300
|
+
resolve(this.resolveDefaultConfig(options));
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
destroy() {
|
|
305
|
+
this.config?.httpAgent?.destroy();
|
|
306
|
+
this.config?.httpsAgent?.destroy();
|
|
307
|
+
}
|
|
308
|
+
async handle(request, { abortSignal, requestTimeout } = {}) {
|
|
309
|
+
if (!this.config) {
|
|
310
|
+
this.config = await this.configProvider;
|
|
311
|
+
}
|
|
312
|
+
const config = this.config;
|
|
313
|
+
const isSSL = request.protocol === "https:";
|
|
314
|
+
if (!isSSL && !this.config.httpAgent) {
|
|
315
|
+
this.config.httpAgent = await this.config.httpAgentProvider();
|
|
316
|
+
}
|
|
317
|
+
return new Promise((_resolve, _reject) => {
|
|
318
|
+
let writeRequestBodyPromise = void 0;
|
|
319
|
+
const timeouts = [];
|
|
320
|
+
const resolve = async (arg) => {
|
|
321
|
+
await writeRequestBodyPromise;
|
|
322
|
+
timeouts.forEach(timing.clearTimeout);
|
|
323
|
+
_resolve(arg);
|
|
324
|
+
};
|
|
325
|
+
const reject = async (arg) => {
|
|
326
|
+
await writeRequestBodyPromise;
|
|
327
|
+
timeouts.forEach(timing.clearTimeout);
|
|
328
|
+
_reject(arg);
|
|
329
|
+
};
|
|
330
|
+
if (abortSignal?.aborted) {
|
|
331
|
+
const abortError = buildAbortError(abortSignal);
|
|
332
|
+
reject(abortError);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const headers = request.headers ?? {};
|
|
336
|
+
const expectContinue = (headers.Expect ?? headers.expect) === "100-continue";
|
|
337
|
+
let agent = isSSL ? config.httpsAgent : config.httpAgent;
|
|
338
|
+
if (expectContinue && !this.externalAgent) {
|
|
339
|
+
agent = new (isSSL ? hsAgent : hAgent)({
|
|
340
|
+
keepAlive: false,
|
|
341
|
+
maxSockets: Infinity
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
timeouts.push(timing.setTimeout(() => {
|
|
345
|
+
this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, config.logger);
|
|
346
|
+
}, config.socketAcquisitionWarningTimeout ?? (config.requestTimeout ?? 2e3) + (config.connectionTimeout ?? 1e3)));
|
|
347
|
+
const queryString = buildQueryString(request.query || {});
|
|
348
|
+
let auth = void 0;
|
|
349
|
+
if (request.username != null || request.password != null) {
|
|
350
|
+
const username = request.username ?? "";
|
|
351
|
+
const password = request.password ?? "";
|
|
352
|
+
auth = `${username}:${password}`;
|
|
353
|
+
}
|
|
354
|
+
let path = request.path;
|
|
355
|
+
if (queryString) {
|
|
356
|
+
path += `?${queryString}`;
|
|
357
|
+
}
|
|
358
|
+
if (request.fragment) {
|
|
359
|
+
path += `#${request.fragment}`;
|
|
360
|
+
}
|
|
361
|
+
let hostname = request.hostname ?? "";
|
|
362
|
+
if (hostname[0] === "[" && hostname.endsWith("]")) {
|
|
363
|
+
hostname = request.hostname.slice(1, -1);
|
|
364
|
+
} else {
|
|
365
|
+
hostname = request.hostname;
|
|
366
|
+
}
|
|
367
|
+
const nodeHttpsOptions = {
|
|
368
|
+
headers: request.headers,
|
|
369
|
+
host: hostname,
|
|
370
|
+
method: request.method,
|
|
371
|
+
path,
|
|
372
|
+
port: request.port,
|
|
373
|
+
agent,
|
|
374
|
+
auth
|
|
375
|
+
};
|
|
376
|
+
const requestFunc = isSSL ? hsRequest : hRequest;
|
|
377
|
+
const req = requestFunc(nodeHttpsOptions, (res) => {
|
|
378
|
+
const httpResponse = new HttpResponse({
|
|
379
|
+
statusCode: res.statusCode || -1,
|
|
380
|
+
reason: res.statusMessage,
|
|
381
|
+
headers: getTransformedHeaders(res.headers),
|
|
382
|
+
body: res
|
|
383
|
+
});
|
|
384
|
+
resolve({ response: httpResponse });
|
|
385
|
+
});
|
|
386
|
+
req.on("error", (err) => {
|
|
387
|
+
if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
|
|
388
|
+
reject(Object.assign(err, { name: "TimeoutError" }));
|
|
389
|
+
} else {
|
|
390
|
+
reject(err);
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
if (abortSignal) {
|
|
394
|
+
const onAbort = () => {
|
|
395
|
+
req.destroy();
|
|
396
|
+
const abortError = buildAbortError(abortSignal);
|
|
397
|
+
reject(abortError);
|
|
398
|
+
};
|
|
399
|
+
if (typeof abortSignal.addEventListener === "function") {
|
|
400
|
+
const signal = abortSignal;
|
|
401
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
402
|
+
req.once("close", () => signal.removeEventListener("abort", onAbort));
|
|
403
|
+
} else {
|
|
404
|
+
abortSignal.onabort = onAbort;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const effectiveRequestTimeout = requestTimeout ?? config.requestTimeout;
|
|
408
|
+
timeouts.push(setConnectionTimeout(req, reject, config.connectionTimeout));
|
|
409
|
+
timeouts.push(setRequestTimeout(req, reject, effectiveRequestTimeout, config.throwOnRequestTimeout, config.logger ?? console));
|
|
410
|
+
timeouts.push(setSocketTimeout(req, reject, config.socketTimeout));
|
|
411
|
+
const httpAgent = nodeHttpsOptions.agent;
|
|
412
|
+
if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
|
|
413
|
+
timeouts.push(setSocketKeepAlive(req, {
|
|
414
|
+
keepAlive: httpAgent.keepAlive,
|
|
415
|
+
keepAliveMsecs: httpAgent.keepAliveMsecs
|
|
416
|
+
}));
|
|
417
|
+
}
|
|
418
|
+
writeRequestBodyPromise = writeRequestBody(req, request, effectiveRequestTimeout, this.externalAgent).catch((e) => {
|
|
419
|
+
timeouts.forEach(timing.clearTimeout);
|
|
420
|
+
return _reject(e);
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
updateHttpClientConfig(key, value) {
|
|
425
|
+
this.config = void 0;
|
|
426
|
+
this.configProvider = this.configProvider.then((config) => {
|
|
427
|
+
return {
|
|
428
|
+
...config,
|
|
429
|
+
[key]: value
|
|
430
|
+
};
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
httpHandlerConfigs() {
|
|
434
|
+
return this.config ?? {};
|
|
435
|
+
}
|
|
436
|
+
resolveDefaultConfig(options) {
|
|
437
|
+
const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent, throwOnRequestTimeout, logger } = options || {};
|
|
438
|
+
const keepAlive = true;
|
|
439
|
+
const maxSockets = 50;
|
|
440
|
+
return {
|
|
441
|
+
connectionTimeout,
|
|
442
|
+
requestTimeout,
|
|
443
|
+
socketTimeout,
|
|
444
|
+
socketAcquisitionWarningTimeout,
|
|
445
|
+
throwOnRequestTimeout,
|
|
446
|
+
httpAgentProvider: async () => {
|
|
447
|
+
const { Agent, request } = await import("http");
|
|
448
|
+
hRequest = request;
|
|
449
|
+
hAgent = Agent;
|
|
450
|
+
if (httpAgent instanceof hAgent || typeof httpAgent?.destroy === "function") {
|
|
451
|
+
this.externalAgent = true;
|
|
452
|
+
return httpAgent;
|
|
453
|
+
}
|
|
454
|
+
return new hAgent({ keepAlive, maxSockets, ...httpAgent });
|
|
455
|
+
},
|
|
456
|
+
httpsAgent: (() => {
|
|
457
|
+
if (httpsAgent instanceof hsAgent || typeof httpsAgent?.destroy === "function") {
|
|
458
|
+
this.externalAgent = true;
|
|
459
|
+
return httpsAgent;
|
|
460
|
+
}
|
|
461
|
+
return new hsAgent({ keepAlive, maxSockets, ...httpsAgent });
|
|
462
|
+
})(),
|
|
463
|
+
logger
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
// ../node_modules/.bun/@smithy+node-http-handler@4.5.1/node_modules/@smithy/node-http-handler/dist-es/stream-collector/collector.js
|
|
469
|
+
import { Writable } from "stream";
|
|
470
|
+
var Collector = class extends Writable {
|
|
471
|
+
bufferedBytes = [];
|
|
472
|
+
_write(chunk, encoding, callback) {
|
|
473
|
+
this.bufferedBytes.push(chunk);
|
|
474
|
+
callback();
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
// ../node_modules/.bun/@smithy+node-http-handler@4.5.1/node_modules/@smithy/node-http-handler/dist-es/stream-collector/index.js
|
|
479
|
+
var streamCollector = (stream) => {
|
|
480
|
+
if (isReadableStreamInstance(stream)) {
|
|
481
|
+
return collectReadableStream(stream);
|
|
482
|
+
}
|
|
483
|
+
return new Promise((resolve, reject) => {
|
|
484
|
+
const collector = new Collector();
|
|
485
|
+
stream.pipe(collector);
|
|
486
|
+
stream.on("error", (err) => {
|
|
487
|
+
collector.end();
|
|
488
|
+
reject(err);
|
|
489
|
+
});
|
|
490
|
+
collector.on("error", reject);
|
|
491
|
+
collector.on("finish", function() {
|
|
492
|
+
const bytes = new Uint8Array(Buffer.concat(this.bufferedBytes));
|
|
493
|
+
resolve(bytes);
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
};
|
|
497
|
+
var isReadableStreamInstance = (stream) => typeof ReadableStream === "function" && stream instanceof ReadableStream;
|
|
498
|
+
async function collectReadableStream(stream) {
|
|
499
|
+
const chunks = [];
|
|
500
|
+
const reader = stream.getReader();
|
|
501
|
+
let isDone = false;
|
|
502
|
+
let length = 0;
|
|
503
|
+
while (!isDone) {
|
|
504
|
+
const { done, value } = await reader.read();
|
|
505
|
+
if (value) {
|
|
506
|
+
chunks.push(value);
|
|
507
|
+
length += value.length;
|
|
508
|
+
}
|
|
509
|
+
isDone = done;
|
|
510
|
+
}
|
|
511
|
+
const collected = new Uint8Array(length);
|
|
512
|
+
let offset = 0;
|
|
513
|
+
for (const chunk of chunks) {
|
|
514
|
+
collected.set(chunk, offset);
|
|
515
|
+
offset += chunk.length;
|
|
516
|
+
}
|
|
517
|
+
return collected;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// ../node_modules/.bun/@smithy+util-base64@4.3.2/node_modules/@smithy/util-base64/dist-es/fromBase64.js
|
|
521
|
+
var BASE64_REGEX = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
522
|
+
var fromBase64 = (input) => {
|
|
523
|
+
if (input.length * 3 % 4 !== 0) {
|
|
524
|
+
throw new TypeError(`Incorrect padding on base64 string.`);
|
|
525
|
+
}
|
|
526
|
+
if (!BASE64_REGEX.exec(input)) {
|
|
527
|
+
throw new TypeError(`Invalid base64 string.`);
|
|
528
|
+
}
|
|
529
|
+
const buffer = fromString(input, "base64");
|
|
530
|
+
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
// ../node_modules/.bun/@smithy+util-base64@4.3.2/node_modules/@smithy/util-base64/dist-es/toBase64.js
|
|
534
|
+
var toBase64 = (_input) => {
|
|
535
|
+
let input;
|
|
536
|
+
if (typeof _input === "string") {
|
|
537
|
+
input = fromUtf8(_input);
|
|
538
|
+
} else {
|
|
539
|
+
input = _input;
|
|
540
|
+
}
|
|
541
|
+
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
542
|
+
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");
|
|
543
|
+
}
|
|
544
|
+
return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("base64");
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
// ../node_modules/.bun/@smithy+util-hex-encoding@4.2.2/node_modules/@smithy/util-hex-encoding/dist-es/index.js
|
|
548
|
+
var SHORT_TO_HEX = {};
|
|
549
|
+
var HEX_TO_SHORT = {};
|
|
550
|
+
for (let i = 0; i < 256; i++) {
|
|
551
|
+
let encodedByte = i.toString(16).toLowerCase();
|
|
552
|
+
if (encodedByte.length === 1) {
|
|
553
|
+
encodedByte = `0${encodedByte}`;
|
|
554
|
+
}
|
|
555
|
+
SHORT_TO_HEX[i] = encodedByte;
|
|
556
|
+
HEX_TO_SHORT[encodedByte] = i;
|
|
557
|
+
}
|
|
558
|
+
function fromHex(encoded) {
|
|
559
|
+
if (encoded.length % 2 !== 0) {
|
|
560
|
+
throw new Error("Hex encoded strings must have an even number length");
|
|
561
|
+
}
|
|
562
|
+
const out = new Uint8Array(encoded.length / 2);
|
|
563
|
+
for (let i = 0; i < encoded.length; i += 2) {
|
|
564
|
+
const encodedByte = encoded.slice(i, i + 2).toLowerCase();
|
|
565
|
+
if (encodedByte in HEX_TO_SHORT) {
|
|
566
|
+
out[i / 2] = HEX_TO_SHORT[encodedByte];
|
|
567
|
+
} else {
|
|
568
|
+
throw new Error(`Cannot decode unrecognized sequence ${encodedByte} as hexadecimal`);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
return out;
|
|
572
|
+
}
|
|
573
|
+
function toHex(bytes) {
|
|
574
|
+
let out = "";
|
|
575
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
576
|
+
out += SHORT_TO_HEX[bytes[i]];
|
|
577
|
+
}
|
|
578
|
+
return out;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
export {
|
|
582
|
+
HttpResponse,
|
|
583
|
+
fromBase64,
|
|
584
|
+
toBase64,
|
|
585
|
+
escapeUri,
|
|
586
|
+
NodeHttpHandler,
|
|
587
|
+
streamCollector,
|
|
588
|
+
fromHex,
|
|
589
|
+
toHex
|
|
590
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// ../node_modules/.bun/@smithy+protocol-http@5.3.12/node_modules/@smithy/protocol-http/dist-es/httpRequest.js
|
|
4
|
+
var HttpRequest = class _HttpRequest {
|
|
5
|
+
method;
|
|
6
|
+
protocol;
|
|
7
|
+
hostname;
|
|
8
|
+
port;
|
|
9
|
+
path;
|
|
10
|
+
query;
|
|
11
|
+
headers;
|
|
12
|
+
username;
|
|
13
|
+
password;
|
|
14
|
+
fragment;
|
|
15
|
+
body;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.method = options.method || "GET";
|
|
18
|
+
this.hostname = options.hostname || "localhost";
|
|
19
|
+
this.port = options.port;
|
|
20
|
+
this.query = options.query || {};
|
|
21
|
+
this.headers = options.headers || {};
|
|
22
|
+
this.body = options.body;
|
|
23
|
+
this.protocol = options.protocol ? options.protocol.slice(-1) !== ":" ? `${options.protocol}:` : options.protocol : "https:";
|
|
24
|
+
this.path = options.path ? options.path.charAt(0) !== "/" ? `/${options.path}` : options.path : "/";
|
|
25
|
+
this.username = options.username;
|
|
26
|
+
this.password = options.password;
|
|
27
|
+
this.fragment = options.fragment;
|
|
28
|
+
}
|
|
29
|
+
static clone(request) {
|
|
30
|
+
const cloned = new _HttpRequest({
|
|
31
|
+
...request,
|
|
32
|
+
headers: { ...request.headers }
|
|
33
|
+
});
|
|
34
|
+
if (cloned.query) {
|
|
35
|
+
cloned.query = cloneQuery(cloned.query);
|
|
36
|
+
}
|
|
37
|
+
return cloned;
|
|
38
|
+
}
|
|
39
|
+
static isInstance(request) {
|
|
40
|
+
if (!request) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const req = request;
|
|
44
|
+
return "method" in req && "protocol" in req && "hostname" in req && "path" in req && typeof req["query"] === "object" && typeof req["headers"] === "object";
|
|
45
|
+
}
|
|
46
|
+
clone() {
|
|
47
|
+
return _HttpRequest.clone(this);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
function cloneQuery(query) {
|
|
51
|
+
return Object.keys(query).reduce((carry, paramName) => {
|
|
52
|
+
const param = query[paramName];
|
|
53
|
+
return {
|
|
54
|
+
...carry,
|
|
55
|
+
[paramName]: Array.isArray(param) ? [...param] : param
|
|
56
|
+
};
|
|
57
|
+
}, {});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
HttpRequest
|
|
62
|
+
};
|