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