nowbackup 1.0.3
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/README.md +392 -0
- package/dist/bin.cjs +36571 -0
- package/dist/bin.js +53 -0
- package/dist/chunk-57ZU5VQ4.js +2994 -0
- package/dist/chunk-6QIWSQ6Y.js +574 -0
- package/dist/chunk-APZ4HNNC.js +1428 -0
- package/dist/chunk-BBB75FHV.js +11988 -0
- package/dist/chunk-FLLLYAHH.js +13 -0
- package/dist/chunk-KKIIHNPF.js +440 -0
- package/dist/chunk-LZQGIK32.js +1388 -0
- package/dist/chunk-SSPSJLWK.js +140 -0
- package/dist/chunk-T7W5F6M2.js +47 -0
- package/dist/chunk-V5IHRGZ2.js +12 -0
- package/dist/chunk-YMVDJI7O.js +3578 -0
- package/dist/chunk-ZHQB65KV.js +4726 -0
- package/dist/dist-es-3KJE4GI3.js +377 -0
- package/dist/dist-es-C4NCVBOK.js +21 -0
- package/dist/dist-es-FJYDFRNF.js +493 -0
- package/dist/dist-es-GOKCIKU2.js +319 -0
- package/dist/dist-es-GYBVDBEN.js +70 -0
- package/dist/dist-es-NQIG67M4.js +164 -0
- package/dist/dist-es-TJCQA2TA.js +89 -0
- package/dist/event-streams-CYRJEQX4.js +41 -0
- package/dist/index.cjs +36537 -0
- package/dist/index.js +15 -0
- package/dist/loadSso-S6XBGQED.js +548 -0
- package/dist/signin-YKKM2Q24.js +643 -0
- package/dist/sso-oidc-YLLTNKNX.js +783 -0
- package/dist/sts-WXTYIV32.js +1387 -0
- package/package.json +64 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
collectBody
|
|
3
|
+
} from "./chunk-YMVDJI7O.js";
|
|
4
|
+
import {
|
|
5
|
+
toUtf8
|
|
6
|
+
} from "./chunk-APZ4HNNC.js";
|
|
7
|
+
|
|
8
|
+
// ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/common.js
|
|
9
|
+
var collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => ((context == null ? void 0 : context.utf8Encoder) ?? toUtf8)(body));
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
collectBodyString
|
|
13
|
+
};
|
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HttpResponse,
|
|
3
|
+
buildQueryString
|
|
4
|
+
} from "./chunk-YMVDJI7O.js";
|
|
5
|
+
|
|
6
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
|
|
7
|
+
import { Agent as hsAgent, request as hsRequest } from "https";
|
|
8
|
+
|
|
9
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/build-abort-error.js
|
|
10
|
+
function buildAbortError(abortSignal) {
|
|
11
|
+
const reason = abortSignal && typeof abortSignal === "object" && "reason" in abortSignal ? abortSignal.reason : void 0;
|
|
12
|
+
if (reason) {
|
|
13
|
+
if (reason instanceof Error) {
|
|
14
|
+
const abortError3 = new Error("Request aborted");
|
|
15
|
+
abortError3.name = "AbortError";
|
|
16
|
+
abortError3.cause = reason;
|
|
17
|
+
return abortError3;
|
|
18
|
+
}
|
|
19
|
+
const abortError2 = new Error(String(reason));
|
|
20
|
+
abortError2.name = "AbortError";
|
|
21
|
+
return abortError2;
|
|
22
|
+
}
|
|
23
|
+
const abortError = new Error("Request aborted");
|
|
24
|
+
abortError.name = "AbortError";
|
|
25
|
+
return abortError;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/constants.js
|
|
29
|
+
var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
|
|
30
|
+
|
|
31
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js
|
|
32
|
+
var getTransformedHeaders = (headers) => {
|
|
33
|
+
const transformedHeaders = {};
|
|
34
|
+
for (const name in headers) {
|
|
35
|
+
const headerValues = headers[name];
|
|
36
|
+
transformedHeaders[name] = Array.isArray(headerValues) ? headerValues.join(",") : headerValues;
|
|
37
|
+
}
|
|
38
|
+
return transformedHeaders;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/timing.js
|
|
42
|
+
var timing = {
|
|
43
|
+
setTimeout: (cb, ms) => setTimeout(cb, ms),
|
|
44
|
+
clearTimeout: (timeoutId) => clearTimeout(timeoutId)
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js
|
|
48
|
+
var DEFER_EVENT_LISTENER_TIME = 1e3;
|
|
49
|
+
var setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
|
|
50
|
+
if (!timeoutInMs) {
|
|
51
|
+
return -1;
|
|
52
|
+
}
|
|
53
|
+
const registerTimeout = (offset) => {
|
|
54
|
+
const timeoutId = timing.setTimeout(() => {
|
|
55
|
+
request.destroy();
|
|
56
|
+
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.`), {
|
|
57
|
+
name: "TimeoutError"
|
|
58
|
+
}));
|
|
59
|
+
}, timeoutInMs - offset);
|
|
60
|
+
const doWithSocket = (socket) => {
|
|
61
|
+
if (socket == null ? void 0 : socket.connecting) {
|
|
62
|
+
socket.on("connect", () => {
|
|
63
|
+
timing.clearTimeout(timeoutId);
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
timing.clearTimeout(timeoutId);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
if (request.socket) {
|
|
70
|
+
doWithSocket(request.socket);
|
|
71
|
+
} else {
|
|
72
|
+
request.on("socket", doWithSocket);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
if (timeoutInMs < 2e3) {
|
|
76
|
+
registerTimeout(0);
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/set-request-timeout.js
|
|
83
|
+
var setRequestTimeout = (req, reject, timeoutInMs = 0, throwOnRequestTimeout, logger) => {
|
|
84
|
+
if (timeoutInMs) {
|
|
85
|
+
return timing.setTimeout(() => {
|
|
86
|
+
var _a;
|
|
87
|
+
let msg = `@smithy/node-http-handler - [${throwOnRequestTimeout ? "ERROR" : "WARN"}] a request has exceeded the configured ${timeoutInMs} ms requestTimeout.`;
|
|
88
|
+
if (throwOnRequestTimeout) {
|
|
89
|
+
const error = Object.assign(new Error(msg), {
|
|
90
|
+
name: "TimeoutError",
|
|
91
|
+
code: "ETIMEDOUT"
|
|
92
|
+
});
|
|
93
|
+
req.destroy(error);
|
|
94
|
+
reject(error);
|
|
95
|
+
} else {
|
|
96
|
+
msg += ` Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.`;
|
|
97
|
+
(_a = logger == null ? void 0 : logger.warn) == null ? void 0 : _a.call(logger, msg);
|
|
98
|
+
}
|
|
99
|
+
}, timeoutInMs);
|
|
100
|
+
}
|
|
101
|
+
return -1;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js
|
|
105
|
+
var DEFER_EVENT_LISTENER_TIME2 = 3e3;
|
|
106
|
+
var setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME2) => {
|
|
107
|
+
if (keepAlive !== true) {
|
|
108
|
+
return -1;
|
|
109
|
+
}
|
|
110
|
+
const registerListener = () => {
|
|
111
|
+
if (request.socket) {
|
|
112
|
+
request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
113
|
+
} else {
|
|
114
|
+
request.on("socket", (socket) => {
|
|
115
|
+
socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
if (deferTimeMs === 0) {
|
|
120
|
+
registerListener();
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
return timing.setTimeout(registerListener, deferTimeMs);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js
|
|
127
|
+
var DEFER_EVENT_LISTENER_TIME3 = 3e3;
|
|
128
|
+
var setSocketTimeout = (request, reject, timeoutInMs = 0) => {
|
|
129
|
+
const registerTimeout = (offset) => {
|
|
130
|
+
const timeout = timeoutInMs - offset;
|
|
131
|
+
const onTimeout = () => {
|
|
132
|
+
request.destroy();
|
|
133
|
+
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" }));
|
|
134
|
+
};
|
|
135
|
+
if (request.socket) {
|
|
136
|
+
request.socket.setTimeout(timeout, onTimeout);
|
|
137
|
+
request.on("close", () => {
|
|
138
|
+
var _a;
|
|
139
|
+
return (_a = request.socket) == null ? void 0 : _a.removeListener("timeout", onTimeout);
|
|
140
|
+
});
|
|
141
|
+
} else {
|
|
142
|
+
request.setTimeout(timeout, onTimeout);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
if (0 < timeoutInMs && timeoutInMs < 6e3) {
|
|
146
|
+
registerTimeout(0);
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME3), DEFER_EVENT_LISTENER_TIME3);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/write-request-body.js
|
|
153
|
+
import { Readable } from "stream";
|
|
154
|
+
var MIN_WAIT_TIME = 6e3;
|
|
155
|
+
async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME, externalAgent = false) {
|
|
156
|
+
const headers = request.headers;
|
|
157
|
+
const expect = headers ? headers.Expect || headers.expect : void 0;
|
|
158
|
+
let timeoutId = -1;
|
|
159
|
+
let sendBody = true;
|
|
160
|
+
if (!externalAgent && expect === "100-continue") {
|
|
161
|
+
sendBody = await Promise.race([
|
|
162
|
+
new Promise((resolve) => {
|
|
163
|
+
timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
164
|
+
}),
|
|
165
|
+
new Promise((resolve) => {
|
|
166
|
+
httpRequest.on("continue", () => {
|
|
167
|
+
timing.clearTimeout(timeoutId);
|
|
168
|
+
resolve(true);
|
|
169
|
+
});
|
|
170
|
+
httpRequest.on("response", () => {
|
|
171
|
+
timing.clearTimeout(timeoutId);
|
|
172
|
+
resolve(false);
|
|
173
|
+
});
|
|
174
|
+
httpRequest.on("error", () => {
|
|
175
|
+
timing.clearTimeout(timeoutId);
|
|
176
|
+
resolve(false);
|
|
177
|
+
});
|
|
178
|
+
})
|
|
179
|
+
]);
|
|
180
|
+
}
|
|
181
|
+
if (sendBody) {
|
|
182
|
+
writeBody(httpRequest, request.body);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function writeBody(httpRequest, body) {
|
|
186
|
+
if (body instanceof Readable) {
|
|
187
|
+
body.pipe(httpRequest);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (body) {
|
|
191
|
+
const isBuffer = Buffer.isBuffer(body);
|
|
192
|
+
const isString = typeof body === "string";
|
|
193
|
+
if (isBuffer || isString) {
|
|
194
|
+
if (isBuffer && body.byteLength === 0) {
|
|
195
|
+
httpRequest.end();
|
|
196
|
+
} else {
|
|
197
|
+
httpRequest.end(body);
|
|
198
|
+
}
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const uint8 = body;
|
|
202
|
+
if (typeof uint8 === "object" && uint8.buffer && typeof uint8.byteOffset === "number" && typeof uint8.byteLength === "number") {
|
|
203
|
+
httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
httpRequest.end(Buffer.from(body));
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
httpRequest.end();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
|
|
213
|
+
var hAgent = void 0;
|
|
214
|
+
var hRequest = void 0;
|
|
215
|
+
var NodeHttpHandler = class _NodeHttpHandler {
|
|
216
|
+
config;
|
|
217
|
+
configProvider;
|
|
218
|
+
socketWarningTimestamp = 0;
|
|
219
|
+
externalAgent = false;
|
|
220
|
+
metadata = { handlerProtocol: "http/1.1" };
|
|
221
|
+
static create(instanceOrOptions) {
|
|
222
|
+
if (typeof (instanceOrOptions == null ? void 0 : instanceOrOptions.handle) === "function") {
|
|
223
|
+
return instanceOrOptions;
|
|
224
|
+
}
|
|
225
|
+
return new _NodeHttpHandler(instanceOrOptions);
|
|
226
|
+
}
|
|
227
|
+
static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
|
|
228
|
+
var _a, _b, _c;
|
|
229
|
+
const { sockets, requests, maxSockets } = agent;
|
|
230
|
+
if (typeof maxSockets !== "number" || maxSockets === Infinity) {
|
|
231
|
+
return socketWarningTimestamp;
|
|
232
|
+
}
|
|
233
|
+
const interval = 15e3;
|
|
234
|
+
if (Date.now() - interval < socketWarningTimestamp) {
|
|
235
|
+
return socketWarningTimestamp;
|
|
236
|
+
}
|
|
237
|
+
if (sockets && requests) {
|
|
238
|
+
for (const origin in sockets) {
|
|
239
|
+
const socketsInUse = ((_a = sockets[origin]) == null ? void 0 : _a.length) ?? 0;
|
|
240
|
+
const requestsEnqueued = ((_b = requests[origin]) == null ? void 0 : _b.length) ?? 0;
|
|
241
|
+
if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
|
|
242
|
+
(_c = logger == null ? void 0 : logger.warn) == null ? void 0 : _c.call(logger, `@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
|
|
243
|
+
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
|
|
244
|
+
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
|
|
245
|
+
return Date.now();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return socketWarningTimestamp;
|
|
250
|
+
}
|
|
251
|
+
constructor(options) {
|
|
252
|
+
this.configProvider = new Promise((resolve, reject) => {
|
|
253
|
+
if (typeof options === "function") {
|
|
254
|
+
options().then((_options) => {
|
|
255
|
+
resolve(this.resolveDefaultConfig(_options));
|
|
256
|
+
}).catch(reject);
|
|
257
|
+
} else {
|
|
258
|
+
resolve(this.resolveDefaultConfig(options));
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
destroy() {
|
|
263
|
+
var _a, _b, _c, _d;
|
|
264
|
+
(_b = (_a = this.config) == null ? void 0 : _a.httpAgent) == null ? void 0 : _b.destroy();
|
|
265
|
+
(_d = (_c = this.config) == null ? void 0 : _c.httpsAgent) == null ? void 0 : _d.destroy();
|
|
266
|
+
}
|
|
267
|
+
async handle(request, { abortSignal, requestTimeout } = {}) {
|
|
268
|
+
if (!this.config) {
|
|
269
|
+
this.config = await this.configProvider;
|
|
270
|
+
}
|
|
271
|
+
const config = this.config;
|
|
272
|
+
const isSSL = request.protocol === "https:";
|
|
273
|
+
if (!isSSL && !this.config.httpAgent) {
|
|
274
|
+
this.config.httpAgent = await this.config.httpAgentProvider();
|
|
275
|
+
}
|
|
276
|
+
return new Promise((_resolve, _reject) => {
|
|
277
|
+
let writeRequestBodyPromise = void 0;
|
|
278
|
+
let socketWarningTimeoutId = -1;
|
|
279
|
+
let connectionTimeoutId = -1;
|
|
280
|
+
let requestTimeoutId = -1;
|
|
281
|
+
let socketTimeoutId = -1;
|
|
282
|
+
let keepAliveTimeoutId = -1;
|
|
283
|
+
const clearTimeouts = () => {
|
|
284
|
+
timing.clearTimeout(socketWarningTimeoutId);
|
|
285
|
+
timing.clearTimeout(connectionTimeoutId);
|
|
286
|
+
timing.clearTimeout(requestTimeoutId);
|
|
287
|
+
timing.clearTimeout(socketTimeoutId);
|
|
288
|
+
timing.clearTimeout(keepAliveTimeoutId);
|
|
289
|
+
};
|
|
290
|
+
const resolve = async (arg) => {
|
|
291
|
+
await writeRequestBodyPromise;
|
|
292
|
+
clearTimeouts();
|
|
293
|
+
_resolve(arg);
|
|
294
|
+
};
|
|
295
|
+
const reject = async (arg) => {
|
|
296
|
+
await writeRequestBodyPromise;
|
|
297
|
+
clearTimeouts();
|
|
298
|
+
_reject(arg);
|
|
299
|
+
};
|
|
300
|
+
if (abortSignal == null ? void 0 : abortSignal.aborted) {
|
|
301
|
+
const abortError = buildAbortError(abortSignal);
|
|
302
|
+
reject(abortError);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const headers = request.headers;
|
|
306
|
+
const expectContinue = headers ? (headers.Expect ?? headers.expect) === "100-continue" : false;
|
|
307
|
+
let agent = isSSL ? config.httpsAgent : config.httpAgent;
|
|
308
|
+
if (expectContinue && !this.externalAgent) {
|
|
309
|
+
agent = new (isSSL ? hsAgent : hAgent)({
|
|
310
|
+
keepAlive: false,
|
|
311
|
+
maxSockets: Infinity
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
socketWarningTimeoutId = timing.setTimeout(() => {
|
|
315
|
+
this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, config.logger);
|
|
316
|
+
}, config.socketAcquisitionWarningTimeout ?? (config.requestTimeout ?? 2e3) + (config.connectionTimeout ?? 1e3));
|
|
317
|
+
const queryString = request.query ? buildQueryString(request.query) : "";
|
|
318
|
+
let auth = void 0;
|
|
319
|
+
if (request.username != null || request.password != null) {
|
|
320
|
+
const username = request.username ?? "";
|
|
321
|
+
const password = request.password ?? "";
|
|
322
|
+
auth = `${username}:${password}`;
|
|
323
|
+
}
|
|
324
|
+
let path = request.path;
|
|
325
|
+
if (queryString) {
|
|
326
|
+
path += `?${queryString}`;
|
|
327
|
+
}
|
|
328
|
+
if (request.fragment) {
|
|
329
|
+
path += `#${request.fragment}`;
|
|
330
|
+
}
|
|
331
|
+
let hostname = request.hostname ?? "";
|
|
332
|
+
if (hostname[0] === "[" && hostname.endsWith("]")) {
|
|
333
|
+
hostname = request.hostname.slice(1, -1);
|
|
334
|
+
} else {
|
|
335
|
+
hostname = request.hostname;
|
|
336
|
+
}
|
|
337
|
+
const nodeHttpsOptions = {
|
|
338
|
+
headers: request.headers,
|
|
339
|
+
host: hostname,
|
|
340
|
+
method: request.method,
|
|
341
|
+
path,
|
|
342
|
+
port: request.port,
|
|
343
|
+
agent,
|
|
344
|
+
auth
|
|
345
|
+
};
|
|
346
|
+
const requestFunc = isSSL ? hsRequest : hRequest;
|
|
347
|
+
const req = requestFunc(nodeHttpsOptions, (res) => {
|
|
348
|
+
const httpResponse = new HttpResponse({
|
|
349
|
+
statusCode: res.statusCode || -1,
|
|
350
|
+
reason: res.statusMessage,
|
|
351
|
+
headers: getTransformedHeaders(res.headers),
|
|
352
|
+
body: res
|
|
353
|
+
});
|
|
354
|
+
resolve({ response: httpResponse });
|
|
355
|
+
});
|
|
356
|
+
req.on("error", (err) => {
|
|
357
|
+
if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
|
|
358
|
+
reject(Object.assign(err, { name: "TimeoutError" }));
|
|
359
|
+
} else {
|
|
360
|
+
reject(err);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
if (abortSignal) {
|
|
364
|
+
const onAbort = () => {
|
|
365
|
+
req.destroy();
|
|
366
|
+
const abortError = buildAbortError(abortSignal);
|
|
367
|
+
reject(abortError);
|
|
368
|
+
};
|
|
369
|
+
if (typeof abortSignal.addEventListener === "function") {
|
|
370
|
+
const signal = abortSignal;
|
|
371
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
372
|
+
req.once("close", () => signal.removeEventListener("abort", onAbort));
|
|
373
|
+
} else {
|
|
374
|
+
abortSignal.onabort = onAbort;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
const effectiveRequestTimeout = requestTimeout ?? config.requestTimeout;
|
|
378
|
+
connectionTimeoutId = setConnectionTimeout(req, reject, config.connectionTimeout);
|
|
379
|
+
requestTimeoutId = setRequestTimeout(req, reject, effectiveRequestTimeout, config.throwOnRequestTimeout, config.logger ?? console);
|
|
380
|
+
socketTimeoutId = setSocketTimeout(req, reject, config.socketTimeout);
|
|
381
|
+
const httpAgent = nodeHttpsOptions.agent;
|
|
382
|
+
if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
|
|
383
|
+
keepAliveTimeoutId = setSocketKeepAlive(req, {
|
|
384
|
+
keepAlive: httpAgent.keepAlive,
|
|
385
|
+
keepAliveMsecs: httpAgent.keepAliveMsecs
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
writeRequestBodyPromise = writeRequestBody(req, request, effectiveRequestTimeout, this.externalAgent).catch((e) => {
|
|
389
|
+
clearTimeouts();
|
|
390
|
+
return _reject(e);
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
updateHttpClientConfig(key, value) {
|
|
395
|
+
this.config = void 0;
|
|
396
|
+
this.configProvider = this.configProvider.then((config) => {
|
|
397
|
+
return {
|
|
398
|
+
...config,
|
|
399
|
+
[key]: value
|
|
400
|
+
};
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
httpHandlerConfigs() {
|
|
404
|
+
return this.config ?? {};
|
|
405
|
+
}
|
|
406
|
+
resolveDefaultConfig(options) {
|
|
407
|
+
const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent, throwOnRequestTimeout, logger } = options || {};
|
|
408
|
+
const keepAlive = true;
|
|
409
|
+
const maxSockets = 50;
|
|
410
|
+
return {
|
|
411
|
+
connectionTimeout,
|
|
412
|
+
requestTimeout,
|
|
413
|
+
socketTimeout,
|
|
414
|
+
socketAcquisitionWarningTimeout,
|
|
415
|
+
throwOnRequestTimeout,
|
|
416
|
+
httpAgentProvider: async () => {
|
|
417
|
+
const { Agent, request } = await import("http");
|
|
418
|
+
hRequest = request;
|
|
419
|
+
hAgent = Agent;
|
|
420
|
+
if (httpAgent instanceof hAgent || typeof (httpAgent == null ? void 0 : httpAgent.destroy) === "function") {
|
|
421
|
+
this.externalAgent = true;
|
|
422
|
+
return httpAgent;
|
|
423
|
+
}
|
|
424
|
+
return new hAgent({ keepAlive, maxSockets, ...httpAgent });
|
|
425
|
+
},
|
|
426
|
+
httpsAgent: (() => {
|
|
427
|
+
if (httpsAgent instanceof hsAgent || typeof (httpsAgent == null ? void 0 : httpsAgent.destroy) === "function") {
|
|
428
|
+
this.externalAgent = true;
|
|
429
|
+
return httpsAgent;
|
|
430
|
+
}
|
|
431
|
+
return new hsAgent({ keepAlive, maxSockets, ...httpsAgent });
|
|
432
|
+
})(),
|
|
433
|
+
logger
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
export {
|
|
439
|
+
NodeHttpHandler
|
|
440
|
+
};
|