@cloudflare/vitest-pool-workers 0.8.52 → 0.8.54
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/pool/index.mjs +1 -1
- package/dist/pool/index.mjs.map +1 -1
- package/dist/worker/index.mjs +1 -1
- package/dist/worker/index.mjs.map +1 -1
- package/dist/worker/lib/cloudflare/mock-agent.cjs +1627 -834
- package/dist/worker/lib/cloudflare/mock-agent.cjs.map +3 -3
- package/dist/worker/lib/cloudflare/test-internal.mjs +17 -13
- package/dist/worker/lib/cloudflare/test-internal.mjs.map +1 -1
- package/package.json +7 -7
- package/types/cloudflare-test.d.ts +1 -1
|
@@ -4,9 +4,10 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
4
4
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
// ../../node_modules/.pnpm/undici@
|
|
7
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/core/symbols.js
|
|
8
8
|
var require_symbols = __commonJS({
|
|
9
|
-
"../../node_modules/.pnpm/undici@
|
|
9
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/core/symbols.js"(exports2, module2) {
|
|
10
|
+
"use strict";
|
|
10
11
|
module2.exports = {
|
|
11
12
|
kClose: Symbol("close"),
|
|
12
13
|
kDestroy: Symbol("destroy"),
|
|
@@ -17,7 +18,6 @@ var require_symbols = __commonJS({
|
|
|
17
18
|
kQueue: Symbol("queue"),
|
|
18
19
|
kConnect: Symbol("connect"),
|
|
19
20
|
kConnecting: Symbol("connecting"),
|
|
20
|
-
kHeadersList: Symbol("headers list"),
|
|
21
21
|
kKeepAliveDefaultTimeout: Symbol("default keep alive timeout"),
|
|
22
22
|
kKeepAliveMaxTimeout: Symbol("max keep alive timeout"),
|
|
23
23
|
kKeepAliveTimeoutThreshold: Symbol("keep alive timeout threshold"),
|
|
@@ -30,6 +30,7 @@ var require_symbols = __commonJS({
|
|
|
30
30
|
kHost: Symbol("host"),
|
|
31
31
|
kNoRef: Symbol("no ref"),
|
|
32
32
|
kBodyUsed: Symbol("used"),
|
|
33
|
+
kBody: Symbol("abstracted request body"),
|
|
33
34
|
kRunning: Symbol("running"),
|
|
34
35
|
kBlocking: Symbol("blocking"),
|
|
35
36
|
kPending: Symbol("pending"),
|
|
@@ -42,6 +43,8 @@ var require_symbols = __commonJS({
|
|
|
42
43
|
kNeedDrain: Symbol("need drain"),
|
|
43
44
|
kReset: Symbol("reset"),
|
|
44
45
|
kDestroyed: Symbol.for("nodejs.stream.destroyed"),
|
|
46
|
+
kResume: Symbol("resume"),
|
|
47
|
+
kOnError: Symbol("on error"),
|
|
45
48
|
kMaxHeadersSize: Symbol("max headers size"),
|
|
46
49
|
kRunningIdx: Symbol("running index"),
|
|
47
50
|
kPendingIdx: Symbol("pending index"),
|
|
@@ -59,71 +62,67 @@ var require_symbols = __commonJS({
|
|
|
59
62
|
kMaxRequests: Symbol("maxRequestsPerClient"),
|
|
60
63
|
kProxy: Symbol("proxy agent options"),
|
|
61
64
|
kCounter: Symbol("socket request counter"),
|
|
62
|
-
kInterceptors: Symbol("dispatch interceptors"),
|
|
63
65
|
kMaxResponseSize: Symbol("max response size"),
|
|
64
66
|
kHTTP2Session: Symbol("http2Session"),
|
|
65
67
|
kHTTP2SessionState: Symbol("http2Session state"),
|
|
66
|
-
kHTTP2BuildRequest: Symbol("http2 build request"),
|
|
67
|
-
kHTTP1BuildRequest: Symbol("http1 build request"),
|
|
68
|
-
kHTTP2CopyHeaders: Symbol("http2 copy headers"),
|
|
69
|
-
kHTTPConnVersion: Symbol("http connection version"),
|
|
70
68
|
kRetryHandlerDefaultRetry: Symbol("retry agent default retry"),
|
|
71
|
-
kConstruct: Symbol("constructable")
|
|
69
|
+
kConstruct: Symbol("constructable"),
|
|
70
|
+
kListeners: Symbol("listeners"),
|
|
71
|
+
kHTTPContext: Symbol("http context"),
|
|
72
|
+
kMaxConcurrentStreams: Symbol("max concurrent streams"),
|
|
73
|
+
kNoProxyAgent: Symbol("no proxy agent"),
|
|
74
|
+
kHttpProxyAgent: Symbol("http proxy agent"),
|
|
75
|
+
kHttpsProxyAgent: Symbol("https proxy agent")
|
|
72
76
|
};
|
|
73
77
|
}
|
|
74
78
|
});
|
|
75
79
|
|
|
76
|
-
// ../../node_modules/.pnpm/undici@
|
|
80
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/core/errors.js
|
|
77
81
|
var require_errors = __commonJS({
|
|
78
|
-
"../../node_modules/.pnpm/undici@
|
|
82
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/core/errors.js"(exports2, module2) {
|
|
79
83
|
"use strict";
|
|
80
84
|
var UndiciError = class extends Error {
|
|
81
|
-
constructor(message) {
|
|
82
|
-
super(message);
|
|
85
|
+
constructor(message, options) {
|
|
86
|
+
super(message, options);
|
|
83
87
|
this.name = "UndiciError";
|
|
84
88
|
this.code = "UND_ERR";
|
|
85
89
|
}
|
|
86
90
|
};
|
|
87
|
-
var ConnectTimeoutError = class
|
|
91
|
+
var ConnectTimeoutError = class extends UndiciError {
|
|
88
92
|
constructor(message) {
|
|
89
93
|
super(message);
|
|
90
|
-
Error.captureStackTrace(this, _ConnectTimeoutError);
|
|
91
94
|
this.name = "ConnectTimeoutError";
|
|
92
95
|
this.message = message || "Connect Timeout Error";
|
|
93
96
|
this.code = "UND_ERR_CONNECT_TIMEOUT";
|
|
94
97
|
}
|
|
95
98
|
};
|
|
96
|
-
var HeadersTimeoutError = class
|
|
99
|
+
var HeadersTimeoutError = class extends UndiciError {
|
|
97
100
|
constructor(message) {
|
|
98
101
|
super(message);
|
|
99
|
-
Error.captureStackTrace(this, _HeadersTimeoutError);
|
|
100
102
|
this.name = "HeadersTimeoutError";
|
|
101
103
|
this.message = message || "Headers Timeout Error";
|
|
102
104
|
this.code = "UND_ERR_HEADERS_TIMEOUT";
|
|
103
105
|
}
|
|
104
106
|
};
|
|
105
|
-
var HeadersOverflowError = class
|
|
107
|
+
var HeadersOverflowError = class extends UndiciError {
|
|
106
108
|
constructor(message) {
|
|
107
109
|
super(message);
|
|
108
|
-
Error.captureStackTrace(this, _HeadersOverflowError);
|
|
109
110
|
this.name = "HeadersOverflowError";
|
|
110
111
|
this.message = message || "Headers Overflow Error";
|
|
111
112
|
this.code = "UND_ERR_HEADERS_OVERFLOW";
|
|
112
113
|
}
|
|
113
114
|
};
|
|
114
|
-
var BodyTimeoutError = class
|
|
115
|
+
var BodyTimeoutError = class extends UndiciError {
|
|
115
116
|
constructor(message) {
|
|
116
117
|
super(message);
|
|
117
|
-
Error.captureStackTrace(this, _BodyTimeoutError);
|
|
118
118
|
this.name = "BodyTimeoutError";
|
|
119
119
|
this.message = message || "Body Timeout Error";
|
|
120
120
|
this.code = "UND_ERR_BODY_TIMEOUT";
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
|
-
var ResponseStatusCodeError = class
|
|
123
|
+
var ResponseStatusCodeError = class extends UndiciError {
|
|
124
124
|
constructor(message, statusCode, headers, body) {
|
|
125
125
|
super(message);
|
|
126
|
-
Error.captureStackTrace(this, _ResponseStatusCodeError);
|
|
127
126
|
this.name = "ResponseStatusCodeError";
|
|
128
127
|
this.message = message || "Response Status Code Error";
|
|
129
128
|
this.code = "UND_ERR_RESPONSE_STATUS_CODE";
|
|
@@ -133,92 +132,89 @@ var require_errors = __commonJS({
|
|
|
133
132
|
this.headers = headers;
|
|
134
133
|
}
|
|
135
134
|
};
|
|
136
|
-
var InvalidArgumentError = class
|
|
135
|
+
var InvalidArgumentError = class extends UndiciError {
|
|
137
136
|
constructor(message) {
|
|
138
137
|
super(message);
|
|
139
|
-
Error.captureStackTrace(this, _InvalidArgumentError);
|
|
140
138
|
this.name = "InvalidArgumentError";
|
|
141
139
|
this.message = message || "Invalid Argument Error";
|
|
142
140
|
this.code = "UND_ERR_INVALID_ARG";
|
|
143
141
|
}
|
|
144
142
|
};
|
|
145
|
-
var InvalidReturnValueError = class
|
|
143
|
+
var InvalidReturnValueError = class extends UndiciError {
|
|
146
144
|
constructor(message) {
|
|
147
145
|
super(message);
|
|
148
|
-
Error.captureStackTrace(this, _InvalidReturnValueError);
|
|
149
146
|
this.name = "InvalidReturnValueError";
|
|
150
147
|
this.message = message || "Invalid Return Value Error";
|
|
151
148
|
this.code = "UND_ERR_INVALID_RETURN_VALUE";
|
|
152
149
|
}
|
|
153
150
|
};
|
|
154
|
-
var
|
|
151
|
+
var AbortError = class extends UndiciError {
|
|
152
|
+
constructor(message) {
|
|
153
|
+
super(message);
|
|
154
|
+
this.name = "AbortError";
|
|
155
|
+
this.message = message || "The operation was aborted";
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
var RequestAbortedError = class extends AbortError {
|
|
155
159
|
constructor(message) {
|
|
156
160
|
super(message);
|
|
157
|
-
Error.captureStackTrace(this, _RequestAbortedError);
|
|
158
161
|
this.name = "AbortError";
|
|
159
162
|
this.message = message || "Request aborted";
|
|
160
163
|
this.code = "UND_ERR_ABORTED";
|
|
161
164
|
}
|
|
162
165
|
};
|
|
163
|
-
var InformationalError = class
|
|
166
|
+
var InformationalError = class extends UndiciError {
|
|
164
167
|
constructor(message) {
|
|
165
168
|
super(message);
|
|
166
|
-
Error.captureStackTrace(this, _InformationalError);
|
|
167
169
|
this.name = "InformationalError";
|
|
168
170
|
this.message = message || "Request information";
|
|
169
171
|
this.code = "UND_ERR_INFO";
|
|
170
172
|
}
|
|
171
173
|
};
|
|
172
|
-
var RequestContentLengthMismatchError = class
|
|
174
|
+
var RequestContentLengthMismatchError = class extends UndiciError {
|
|
173
175
|
constructor(message) {
|
|
174
176
|
super(message);
|
|
175
|
-
Error.captureStackTrace(this, _RequestContentLengthMismatchError);
|
|
176
177
|
this.name = "RequestContentLengthMismatchError";
|
|
177
178
|
this.message = message || "Request body length does not match content-length header";
|
|
178
179
|
this.code = "UND_ERR_REQ_CONTENT_LENGTH_MISMATCH";
|
|
179
180
|
}
|
|
180
181
|
};
|
|
181
|
-
var ResponseContentLengthMismatchError = class
|
|
182
|
+
var ResponseContentLengthMismatchError = class extends UndiciError {
|
|
182
183
|
constructor(message) {
|
|
183
184
|
super(message);
|
|
184
|
-
Error.captureStackTrace(this, _ResponseContentLengthMismatchError);
|
|
185
185
|
this.name = "ResponseContentLengthMismatchError";
|
|
186
186
|
this.message = message || "Response body length does not match content-length header";
|
|
187
187
|
this.code = "UND_ERR_RES_CONTENT_LENGTH_MISMATCH";
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
|
-
var ClientDestroyedError = class
|
|
190
|
+
var ClientDestroyedError = class extends UndiciError {
|
|
191
191
|
constructor(message) {
|
|
192
192
|
super(message);
|
|
193
|
-
Error.captureStackTrace(this, _ClientDestroyedError);
|
|
194
193
|
this.name = "ClientDestroyedError";
|
|
195
194
|
this.message = message || "The client is destroyed";
|
|
196
195
|
this.code = "UND_ERR_DESTROYED";
|
|
197
196
|
}
|
|
198
197
|
};
|
|
199
|
-
var ClientClosedError = class
|
|
198
|
+
var ClientClosedError = class extends UndiciError {
|
|
200
199
|
constructor(message) {
|
|
201
200
|
super(message);
|
|
202
|
-
Error.captureStackTrace(this, _ClientClosedError);
|
|
203
201
|
this.name = "ClientClosedError";
|
|
204
202
|
this.message = message || "The client is closed";
|
|
205
203
|
this.code = "UND_ERR_CLOSED";
|
|
206
204
|
}
|
|
207
205
|
};
|
|
208
|
-
var SocketError = class
|
|
206
|
+
var SocketError = class extends UndiciError {
|
|
209
207
|
constructor(message, socket) {
|
|
210
208
|
super(message);
|
|
211
|
-
Error.captureStackTrace(this, _SocketError);
|
|
212
209
|
this.name = "SocketError";
|
|
213
210
|
this.message = message || "Socket error";
|
|
214
211
|
this.code = "UND_ERR_SOCKET";
|
|
215
212
|
this.socket = socket;
|
|
216
213
|
}
|
|
217
214
|
};
|
|
218
|
-
var NotSupportedError = class
|
|
215
|
+
var NotSupportedError = class extends UndiciError {
|
|
219
216
|
constructor(message) {
|
|
220
217
|
super(message);
|
|
221
|
-
Error.captureStackTrace(this, _NotSupportedError);
|
|
222
218
|
this.name = "NotSupportedError";
|
|
223
219
|
this.message = message || "Not supported error";
|
|
224
220
|
this.code = "UND_ERR_NOT_SUPPORTED";
|
|
@@ -227,34 +223,30 @@ var require_errors = __commonJS({
|
|
|
227
223
|
var BalancedPoolMissingUpstreamError = class extends UndiciError {
|
|
228
224
|
constructor(message) {
|
|
229
225
|
super(message);
|
|
230
|
-
Error.captureStackTrace(this, NotSupportedError);
|
|
231
226
|
this.name = "MissingUpstreamError";
|
|
232
227
|
this.message = message || "No upstream has been added to the BalancedPool";
|
|
233
228
|
this.code = "UND_ERR_BPL_MISSING_UPSTREAM";
|
|
234
229
|
}
|
|
235
230
|
};
|
|
236
|
-
var HTTPParserError = class
|
|
231
|
+
var HTTPParserError = class extends Error {
|
|
237
232
|
constructor(message, code, data) {
|
|
238
233
|
super(message);
|
|
239
|
-
Error.captureStackTrace(this, _HTTPParserError);
|
|
240
234
|
this.name = "HTTPParserError";
|
|
241
235
|
this.code = code ? `HPE_${code}` : void 0;
|
|
242
236
|
this.data = data ? data.toString() : void 0;
|
|
243
237
|
}
|
|
244
238
|
};
|
|
245
|
-
var ResponseExceededMaxSizeError = class
|
|
239
|
+
var ResponseExceededMaxSizeError = class extends UndiciError {
|
|
246
240
|
constructor(message) {
|
|
247
241
|
super(message);
|
|
248
|
-
Error.captureStackTrace(this, _ResponseExceededMaxSizeError);
|
|
249
242
|
this.name = "ResponseExceededMaxSizeError";
|
|
250
243
|
this.message = message || "Response content exceeded max size";
|
|
251
244
|
this.code = "UND_ERR_RES_EXCEEDED_MAX_SIZE";
|
|
252
245
|
}
|
|
253
246
|
};
|
|
254
|
-
var RequestRetryError = class
|
|
247
|
+
var RequestRetryError = class extends UndiciError {
|
|
255
248
|
constructor(message, code, { headers, data }) {
|
|
256
249
|
super(message);
|
|
257
|
-
Error.captureStackTrace(this, _RequestRetryError);
|
|
258
250
|
this.name = "RequestRetryError";
|
|
259
251
|
this.message = message || "Request retry error";
|
|
260
252
|
this.code = "UND_ERR_REQ_RETRY";
|
|
@@ -263,7 +255,28 @@ var require_errors = __commonJS({
|
|
|
263
255
|
this.headers = headers;
|
|
264
256
|
}
|
|
265
257
|
};
|
|
258
|
+
var ResponseError = class extends UndiciError {
|
|
259
|
+
constructor(message, code, { headers, body }) {
|
|
260
|
+
super(message);
|
|
261
|
+
this.name = "ResponseError";
|
|
262
|
+
this.message = message || "Response error";
|
|
263
|
+
this.code = "UND_ERR_RESPONSE";
|
|
264
|
+
this.statusCode = code;
|
|
265
|
+
this.body = body;
|
|
266
|
+
this.headers = headers;
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
var SecureProxyConnectionError = class extends UndiciError {
|
|
270
|
+
constructor(cause, message, options = {}) {
|
|
271
|
+
super(message, { cause, ...options });
|
|
272
|
+
this.name = "SecureProxyConnectionError";
|
|
273
|
+
this.message = message || "Secure Proxy Connection failed";
|
|
274
|
+
this.code = "UND_ERR_PRX_TLS";
|
|
275
|
+
this.cause = cause;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
266
278
|
module2.exports = {
|
|
279
|
+
AbortError,
|
|
267
280
|
HTTPParserError,
|
|
268
281
|
UndiciError,
|
|
269
282
|
HeadersTimeoutError,
|
|
@@ -283,385 +296,699 @@ var require_errors = __commonJS({
|
|
|
283
296
|
ResponseContentLengthMismatchError,
|
|
284
297
|
BalancedPoolMissingUpstreamError,
|
|
285
298
|
ResponseExceededMaxSizeError,
|
|
286
|
-
RequestRetryError
|
|
299
|
+
RequestRetryError,
|
|
300
|
+
ResponseError,
|
|
301
|
+
SecureProxyConnectionError
|
|
287
302
|
};
|
|
288
303
|
}
|
|
289
304
|
});
|
|
290
305
|
|
|
291
|
-
// ../../node_modules/.pnpm/undici@
|
|
292
|
-
var
|
|
293
|
-
"../../node_modules/.pnpm/undici@
|
|
306
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/handler/wrap-handler.js
|
|
307
|
+
var require_wrap_handler = __commonJS({
|
|
308
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/handler/wrap-handler.js"(exports2, module2) {
|
|
294
309
|
"use strict";
|
|
295
|
-
var
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
310
|
+
var { InvalidArgumentError } = require_errors();
|
|
311
|
+
module2.exports = class WrapHandler {
|
|
312
|
+
#handler;
|
|
313
|
+
constructor(handler) {
|
|
314
|
+
this.#handler = handler;
|
|
299
315
|
}
|
|
300
|
-
|
|
301
|
-
|
|
316
|
+
static wrap(handler) {
|
|
317
|
+
return handler.onRequestStart ? handler : new WrapHandler(handler);
|
|
302
318
|
}
|
|
303
|
-
|
|
304
|
-
|
|
319
|
+
// Unwrap Interface
|
|
320
|
+
onConnect(abort, context) {
|
|
321
|
+
return this.#handler.onConnect?.(abort, context);
|
|
305
322
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
// ../../node_modules/.pnpm/undici@5.28.5/node_modules/undici/lib/dispatcher-base.js
|
|
312
|
-
var require_dispatcher_base = __commonJS({
|
|
313
|
-
"../../node_modules/.pnpm/undici@5.28.5/node_modules/undici/lib/dispatcher-base.js"(exports2, module2) {
|
|
314
|
-
"use strict";
|
|
315
|
-
var Dispatcher = require_dispatcher();
|
|
316
|
-
var {
|
|
317
|
-
ClientDestroyedError,
|
|
318
|
-
ClientClosedError,
|
|
319
|
-
InvalidArgumentError
|
|
320
|
-
} = require_errors();
|
|
321
|
-
var { kDestroy, kClose, kDispatch, kInterceptors } = require_symbols();
|
|
322
|
-
var kDestroyed = Symbol("destroyed");
|
|
323
|
-
var kClosed = Symbol("closed");
|
|
324
|
-
var kOnDestroyed = Symbol("onDestroyed");
|
|
325
|
-
var kOnClosed = Symbol("onClosed");
|
|
326
|
-
var kInterceptedDispatch = Symbol("Intercepted Dispatch");
|
|
327
|
-
var DispatcherBase = class extends Dispatcher {
|
|
328
|
-
constructor() {
|
|
329
|
-
super();
|
|
330
|
-
this[kDestroyed] = false;
|
|
331
|
-
this[kOnDestroyed] = null;
|
|
332
|
-
this[kClosed] = false;
|
|
333
|
-
this[kOnClosed] = [];
|
|
323
|
+
onHeaders(statusCode, rawHeaders, resume, statusMessage) {
|
|
324
|
+
return this.#handler.onHeaders?.(statusCode, rawHeaders, resume, statusMessage);
|
|
334
325
|
}
|
|
335
|
-
|
|
336
|
-
return this
|
|
326
|
+
onUpgrade(statusCode, rawHeaders, socket) {
|
|
327
|
+
return this.#handler.onUpgrade?.(statusCode, rawHeaders, socket);
|
|
337
328
|
}
|
|
338
|
-
|
|
339
|
-
return this
|
|
329
|
+
onData(data) {
|
|
330
|
+
return this.#handler.onData?.(data);
|
|
340
331
|
}
|
|
341
|
-
|
|
342
|
-
return this
|
|
332
|
+
onComplete(trailers) {
|
|
333
|
+
return this.#handler.onComplete?.(trailers);
|
|
343
334
|
}
|
|
344
|
-
|
|
345
|
-
if (
|
|
346
|
-
|
|
347
|
-
const interceptor = this[kInterceptors][i];
|
|
348
|
-
if (typeof interceptor !== "function") {
|
|
349
|
-
throw new InvalidArgumentError("interceptor must be an function");
|
|
350
|
-
}
|
|
351
|
-
}
|
|
335
|
+
onError(err) {
|
|
336
|
+
if (!this.#handler.onError) {
|
|
337
|
+
throw err;
|
|
352
338
|
}
|
|
353
|
-
this
|
|
339
|
+
return this.#handler.onError?.(err);
|
|
354
340
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
this.close((err, data) => {
|
|
359
|
-
return err ? reject(err) : resolve(data);
|
|
360
|
-
});
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
if (typeof callback !== "function") {
|
|
364
|
-
throw new InvalidArgumentError("invalid callback");
|
|
365
|
-
}
|
|
366
|
-
if (this[kDestroyed]) {
|
|
367
|
-
queueMicrotask(() => callback(new ClientDestroyedError(), null));
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
if (this[kClosed]) {
|
|
371
|
-
if (this[kOnClosed]) {
|
|
372
|
-
this[kOnClosed].push(callback);
|
|
373
|
-
} else {
|
|
374
|
-
queueMicrotask(() => callback(null, null));
|
|
375
|
-
}
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
this[kClosed] = true;
|
|
379
|
-
this[kOnClosed].push(callback);
|
|
380
|
-
const onClosed = () => {
|
|
381
|
-
const callbacks = this[kOnClosed];
|
|
382
|
-
this[kOnClosed] = null;
|
|
383
|
-
for (let i = 0; i < callbacks.length; i++) {
|
|
384
|
-
callbacks[i](null, null);
|
|
385
|
-
}
|
|
386
|
-
};
|
|
387
|
-
this[kClose]().then(() => this.destroy()).then(() => {
|
|
388
|
-
queueMicrotask(onClosed);
|
|
389
|
-
});
|
|
341
|
+
// Wrap Interface
|
|
342
|
+
onRequestStart(controller, context) {
|
|
343
|
+
this.#handler.onConnect?.((reason) => controller.abort(reason), context);
|
|
390
344
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
345
|
+
onRequestUpgrade(controller, statusCode, headers, socket) {
|
|
346
|
+
const rawHeaders = [];
|
|
347
|
+
for (const [key, val] of Object.entries(headers)) {
|
|
348
|
+
rawHeaders.push(Buffer.from(key), Array.isArray(val) ? val.map((v) => Buffer.from(v)) : Buffer.from(val));
|
|
395
349
|
}
|
|
396
|
-
|
|
397
|
-
return new Promise((resolve, reject) => {
|
|
398
|
-
this.destroy(err, (err2, data) => {
|
|
399
|
-
return err2 ? (
|
|
400
|
-
/* istanbul ignore next: should never error */
|
|
401
|
-
reject(err2)
|
|
402
|
-
) : resolve(data);
|
|
403
|
-
});
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
if (typeof callback !== "function") {
|
|
407
|
-
throw new InvalidArgumentError("invalid callback");
|
|
408
|
-
}
|
|
409
|
-
if (this[kDestroyed]) {
|
|
410
|
-
if (this[kOnDestroyed]) {
|
|
411
|
-
this[kOnDestroyed].push(callback);
|
|
412
|
-
} else {
|
|
413
|
-
queueMicrotask(() => callback(null, null));
|
|
414
|
-
}
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
if (!err) {
|
|
418
|
-
err = new ClientDestroyedError();
|
|
419
|
-
}
|
|
420
|
-
this[kDestroyed] = true;
|
|
421
|
-
this[kOnDestroyed] = this[kOnDestroyed] || [];
|
|
422
|
-
this[kOnDestroyed].push(callback);
|
|
423
|
-
const onDestroyed = () => {
|
|
424
|
-
const callbacks = this[kOnDestroyed];
|
|
425
|
-
this[kOnDestroyed] = null;
|
|
426
|
-
for (let i = 0; i < callbacks.length; i++) {
|
|
427
|
-
callbacks[i](null, null);
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
this[kDestroy](err).then(() => {
|
|
431
|
-
queueMicrotask(onDestroyed);
|
|
432
|
-
});
|
|
350
|
+
this.#handler.onUpgrade?.(statusCode, rawHeaders, socket);
|
|
433
351
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
352
|
+
onResponseStart(controller, statusCode, headers, statusMessage) {
|
|
353
|
+
const rawHeaders = [];
|
|
354
|
+
for (const [key, val] of Object.entries(headers)) {
|
|
355
|
+
rawHeaders.push(Buffer.from(key), Array.isArray(val) ? val.map((v) => Buffer.from(v)) : Buffer.from(val));
|
|
438
356
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
dispatch = this[kInterceptors][i](dispatch);
|
|
357
|
+
if (this.#handler.onHeaders?.(statusCode, rawHeaders, () => controller.resume(), statusMessage) === false) {
|
|
358
|
+
controller.pause();
|
|
442
359
|
}
|
|
443
|
-
this[kInterceptedDispatch] = dispatch;
|
|
444
|
-
return dispatch(opts, handler);
|
|
445
360
|
}
|
|
446
|
-
|
|
447
|
-
if (
|
|
448
|
-
|
|
361
|
+
onResponseData(controller, data) {
|
|
362
|
+
if (this.#handler.onData?.(data) === false) {
|
|
363
|
+
controller.pause();
|
|
449
364
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
throw new ClientDestroyedError();
|
|
456
|
-
}
|
|
457
|
-
if (this[kClosed]) {
|
|
458
|
-
throw new ClientClosedError();
|
|
459
|
-
}
|
|
460
|
-
return this[kInterceptedDispatch](opts, handler);
|
|
461
|
-
} catch (err) {
|
|
462
|
-
if (typeof handler.onError !== "function") {
|
|
463
|
-
throw new InvalidArgumentError("invalid onError method");
|
|
464
|
-
}
|
|
465
|
-
handler.onError(err);
|
|
466
|
-
return false;
|
|
365
|
+
}
|
|
366
|
+
onResponseEnd(controller, trailers) {
|
|
367
|
+
const rawTrailers = [];
|
|
368
|
+
for (const [key, val] of Object.entries(trailers)) {
|
|
369
|
+
rawTrailers.push(Buffer.from(key), Array.isArray(val) ? val.map((v) => Buffer.from(v)) : Buffer.from(val));
|
|
467
370
|
}
|
|
371
|
+
this.#handler.onComplete?.(rawTrailers);
|
|
468
372
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
// src/mock-agent/pool.cjs
|
|
475
|
-
var require_pool = __commonJS({
|
|
476
|
-
"src/mock-agent/pool.cjs"(exports2, module2) {
|
|
477
|
-
var assert = require("node:assert");
|
|
478
|
-
module2.exports = class Pool {
|
|
479
|
-
constructor() {
|
|
480
|
-
assert.fail("Pool is not implemented in worker");
|
|
373
|
+
onResponseError(controller, err) {
|
|
374
|
+
if (!this.#handler.onError) {
|
|
375
|
+
throw new InvalidArgumentError("invalid onError method");
|
|
376
|
+
}
|
|
377
|
+
this.#handler.onError?.(err);
|
|
481
378
|
}
|
|
482
379
|
};
|
|
483
380
|
}
|
|
484
381
|
});
|
|
485
382
|
|
|
486
|
-
//
|
|
487
|
-
var
|
|
488
|
-
"
|
|
383
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/dispatcher/dispatcher.js
|
|
384
|
+
var require_dispatcher = __commonJS({
|
|
385
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/dispatcher/dispatcher.js"(exports2, module2) {
|
|
489
386
|
"use strict";
|
|
490
|
-
var
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
387
|
+
var EventEmitter = require("node:events");
|
|
388
|
+
var WrapHandler = require_wrap_handler();
|
|
389
|
+
var wrapInterceptor = (dispatch) => (opts, handler) => dispatch(opts, WrapHandler.wrap(handler));
|
|
390
|
+
var Dispatcher = class extends EventEmitter {
|
|
391
|
+
dispatch() {
|
|
392
|
+
throw new Error("not implemented");
|
|
393
|
+
}
|
|
394
|
+
close() {
|
|
395
|
+
throw new Error("not implemented");
|
|
396
|
+
}
|
|
397
|
+
destroy() {
|
|
398
|
+
throw new Error("not implemented");
|
|
399
|
+
}
|
|
400
|
+
compose(...args) {
|
|
401
|
+
const interceptors = Array.isArray(args[0]) ? args[0] : args;
|
|
402
|
+
let dispatch = this.dispatch.bind(this);
|
|
403
|
+
for (const interceptor of interceptors) {
|
|
404
|
+
if (interceptor == null) {
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
if (typeof interceptor !== "function") {
|
|
408
|
+
throw new TypeError(`invalid interceptor, expected function received ${typeof interceptor}`);
|
|
409
|
+
}
|
|
410
|
+
dispatch = interceptor(dispatch);
|
|
411
|
+
dispatch = wrapInterceptor(dispatch);
|
|
412
|
+
if (dispatch == null || typeof dispatch !== "function" || dispatch.length !== 2) {
|
|
413
|
+
throw new TypeError("invalid interceptor");
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return new Proxy(this, {
|
|
417
|
+
get: (target, key) => key === "dispatch" ? dispatch : target[key]
|
|
418
|
+
});
|
|
497
419
|
}
|
|
498
420
|
};
|
|
421
|
+
module2.exports = Dispatcher;
|
|
499
422
|
}
|
|
500
423
|
});
|
|
501
424
|
|
|
502
|
-
//
|
|
503
|
-
var
|
|
504
|
-
"
|
|
505
|
-
|
|
506
|
-
var
|
|
507
|
-
var
|
|
508
|
-
var
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
425
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/util/timers.js
|
|
426
|
+
var require_timers = __commonJS({
|
|
427
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/util/timers.js"(exports2, module2) {
|
|
428
|
+
"use strict";
|
|
429
|
+
var fastNow = 0;
|
|
430
|
+
var RESOLUTION_MS = 1e3;
|
|
431
|
+
var TICK_MS = (RESOLUTION_MS >> 1) - 1;
|
|
432
|
+
var fastNowTimeout;
|
|
433
|
+
var kFastTimer = Symbol("kFastTimer");
|
|
434
|
+
var fastTimers = [];
|
|
435
|
+
var NOT_IN_LIST = -2;
|
|
436
|
+
var TO_BE_CLEARED = -1;
|
|
437
|
+
var PENDING = 0;
|
|
438
|
+
var ACTIVE = 1;
|
|
439
|
+
function onTick() {
|
|
440
|
+
fastNow += TICK_MS;
|
|
441
|
+
let idx = 0;
|
|
442
|
+
let len = fastTimers.length;
|
|
443
|
+
while (idx < len) {
|
|
444
|
+
const timer = fastTimers[idx];
|
|
445
|
+
if (timer._state === PENDING) {
|
|
446
|
+
timer._idleStart = fastNow - TICK_MS;
|
|
447
|
+
timer._state = ACTIVE;
|
|
448
|
+
} else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) {
|
|
449
|
+
timer._state = TO_BE_CLEARED;
|
|
450
|
+
timer._idleStart = -1;
|
|
451
|
+
timer._onTimeout(timer._timerArg);
|
|
452
|
+
}
|
|
453
|
+
if (timer._state === TO_BE_CLEARED) {
|
|
454
|
+
timer._state = NOT_IN_LIST;
|
|
455
|
+
if (--len !== 0) {
|
|
456
|
+
fastTimers[idx] = fastTimers[len];
|
|
457
|
+
}
|
|
458
|
+
} else {
|
|
459
|
+
++idx;
|
|
514
460
|
}
|
|
515
|
-
dispatcher(opts, handler);
|
|
516
|
-
return true;
|
|
517
461
|
}
|
|
518
|
-
|
|
462
|
+
fastTimers.length = len;
|
|
463
|
+
if (fastTimers.length !== 0) {
|
|
464
|
+
refreshTimeout();
|
|
519
465
|
}
|
|
520
|
-
|
|
466
|
+
}
|
|
467
|
+
function refreshTimeout() {
|
|
468
|
+
if (fastNowTimeout?.refresh) {
|
|
469
|
+
fastNowTimeout.refresh();
|
|
470
|
+
} else {
|
|
471
|
+
clearTimeout(fastNowTimeout);
|
|
472
|
+
fastNowTimeout = setTimeout(onTick, TICK_MS);
|
|
473
|
+
fastNowTimeout?.unref();
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
var FastTimer = class {
|
|
477
|
+
[kFastTimer] = true;
|
|
478
|
+
/**
|
|
479
|
+
* The state of the timer, which can be one of the following:
|
|
480
|
+
* - NOT_IN_LIST (-2)
|
|
481
|
+
* - TO_BE_CLEARED (-1)
|
|
482
|
+
* - PENDING (0)
|
|
483
|
+
* - ACTIVE (1)
|
|
484
|
+
*
|
|
485
|
+
* @type {-2|-1|0|1}
|
|
486
|
+
* @private
|
|
487
|
+
*/
|
|
488
|
+
_state = NOT_IN_LIST;
|
|
489
|
+
/**
|
|
490
|
+
* The number of milliseconds to wait before calling the callback.
|
|
491
|
+
*
|
|
492
|
+
* @type {number}
|
|
493
|
+
* @private
|
|
494
|
+
*/
|
|
495
|
+
_idleTimeout = -1;
|
|
496
|
+
/**
|
|
497
|
+
* The time in milliseconds when the timer was started. This value is used to
|
|
498
|
+
* calculate when the timer should expire.
|
|
499
|
+
*
|
|
500
|
+
* @type {number}
|
|
501
|
+
* @default -1
|
|
502
|
+
* @private
|
|
503
|
+
*/
|
|
504
|
+
_idleStart = -1;
|
|
505
|
+
/**
|
|
506
|
+
* The function to be executed when the timer expires.
|
|
507
|
+
* @type {Function}
|
|
508
|
+
* @private
|
|
509
|
+
*/
|
|
510
|
+
_onTimeout;
|
|
511
|
+
/**
|
|
512
|
+
* The argument to be passed to the callback when the timer expires.
|
|
513
|
+
*
|
|
514
|
+
* @type {*}
|
|
515
|
+
* @private
|
|
516
|
+
*/
|
|
517
|
+
_timerArg;
|
|
518
|
+
/**
|
|
519
|
+
* @constructor
|
|
520
|
+
* @param {Function} callback A function to be executed after the timer
|
|
521
|
+
* expires.
|
|
522
|
+
* @param {number} delay The time, in milliseconds that the timer should wait
|
|
523
|
+
* before the specified function or code is executed.
|
|
524
|
+
* @param {*} arg
|
|
525
|
+
*/
|
|
526
|
+
constructor(callback, delay, arg) {
|
|
527
|
+
this._onTimeout = callback;
|
|
528
|
+
this._idleTimeout = delay;
|
|
529
|
+
this._timerArg = arg;
|
|
530
|
+
this.refresh();
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Sets the timer's start time to the current time, and reschedules the timer
|
|
534
|
+
* to call its callback at the previously specified duration adjusted to the
|
|
535
|
+
* current time.
|
|
536
|
+
* Using this on a timer that has already called its callback will reactivate
|
|
537
|
+
* the timer.
|
|
538
|
+
*
|
|
539
|
+
* @returns {void}
|
|
540
|
+
*/
|
|
541
|
+
refresh() {
|
|
542
|
+
if (this._state === NOT_IN_LIST) {
|
|
543
|
+
fastTimers.push(this);
|
|
544
|
+
}
|
|
545
|
+
if (!fastNowTimeout || fastTimers.length === 1) {
|
|
546
|
+
refreshTimeout();
|
|
547
|
+
}
|
|
548
|
+
this._state = PENDING;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* The `clear` method cancels the timer, preventing it from executing.
|
|
552
|
+
*
|
|
553
|
+
* @returns {void}
|
|
554
|
+
* @private
|
|
555
|
+
*/
|
|
556
|
+
clear() {
|
|
557
|
+
this._state = TO_BE_CLEARED;
|
|
558
|
+
this._idleStart = -1;
|
|
521
559
|
}
|
|
522
560
|
};
|
|
561
|
+
module2.exports = {
|
|
562
|
+
/**
|
|
563
|
+
* The setTimeout() method sets a timer which executes a function once the
|
|
564
|
+
* timer expires.
|
|
565
|
+
* @param {Function} callback A function to be executed after the timer
|
|
566
|
+
* expires.
|
|
567
|
+
* @param {number} delay The time, in milliseconds that the timer should
|
|
568
|
+
* wait before the specified function or code is executed.
|
|
569
|
+
* @param {*} [arg] An optional argument to be passed to the callback function
|
|
570
|
+
* when the timer expires.
|
|
571
|
+
* @returns {NodeJS.Timeout|FastTimer}
|
|
572
|
+
*/
|
|
573
|
+
setTimeout(callback, delay, arg) {
|
|
574
|
+
return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg);
|
|
575
|
+
},
|
|
576
|
+
/**
|
|
577
|
+
* The clearTimeout method cancels an instantiated Timer previously created
|
|
578
|
+
* by calling setTimeout.
|
|
579
|
+
*
|
|
580
|
+
* @param {NodeJS.Timeout|FastTimer} timeout
|
|
581
|
+
*/
|
|
582
|
+
clearTimeout(timeout) {
|
|
583
|
+
if (timeout[kFastTimer]) {
|
|
584
|
+
timeout.clear();
|
|
585
|
+
} else {
|
|
586
|
+
clearTimeout(timeout);
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
/**
|
|
590
|
+
* The setFastTimeout() method sets a fastTimer which executes a function once
|
|
591
|
+
* the timer expires.
|
|
592
|
+
* @param {Function} callback A function to be executed after the timer
|
|
593
|
+
* expires.
|
|
594
|
+
* @param {number} delay The time, in milliseconds that the timer should
|
|
595
|
+
* wait before the specified function or code is executed.
|
|
596
|
+
* @param {*} [arg] An optional argument to be passed to the callback function
|
|
597
|
+
* when the timer expires.
|
|
598
|
+
* @returns {FastTimer}
|
|
599
|
+
*/
|
|
600
|
+
setFastTimeout(callback, delay, arg) {
|
|
601
|
+
return new FastTimer(callback, delay, arg);
|
|
602
|
+
},
|
|
603
|
+
/**
|
|
604
|
+
* The clearTimeout method cancels an instantiated FastTimer previously
|
|
605
|
+
* created by calling setFastTimeout.
|
|
606
|
+
*
|
|
607
|
+
* @param {FastTimer} timeout
|
|
608
|
+
*/
|
|
609
|
+
clearFastTimeout(timeout) {
|
|
610
|
+
timeout.clear();
|
|
611
|
+
},
|
|
612
|
+
/**
|
|
613
|
+
* The now method returns the value of the internal fast timer clock.
|
|
614
|
+
*
|
|
615
|
+
* @returns {number}
|
|
616
|
+
*/
|
|
617
|
+
now() {
|
|
618
|
+
return fastNow;
|
|
619
|
+
},
|
|
620
|
+
/**
|
|
621
|
+
* Trigger the onTick function to process the fastTimers array.
|
|
622
|
+
* Exported for testing purposes only.
|
|
623
|
+
* Marking as deprecated to discourage any use outside of testing.
|
|
624
|
+
* @deprecated
|
|
625
|
+
* @param {number} [delay=0] The delay in milliseconds to add to the now value.
|
|
626
|
+
*/
|
|
627
|
+
tick(delay = 0) {
|
|
628
|
+
fastNow += delay - RESOLUTION_MS + 1;
|
|
629
|
+
onTick();
|
|
630
|
+
onTick();
|
|
631
|
+
},
|
|
632
|
+
/**
|
|
633
|
+
* Reset FastTimers.
|
|
634
|
+
* Exported for testing purposes only.
|
|
635
|
+
* Marking as deprecated to discourage any use outside of testing.
|
|
636
|
+
* @deprecated
|
|
637
|
+
*/
|
|
638
|
+
reset() {
|
|
639
|
+
fastNow = 0;
|
|
640
|
+
fastTimers.length = 0;
|
|
641
|
+
clearTimeout(fastNowTimeout);
|
|
642
|
+
fastNowTimeout = null;
|
|
643
|
+
},
|
|
644
|
+
/**
|
|
645
|
+
* Exporting for testing purposes only.
|
|
646
|
+
* Marking as deprecated to discourage any use outside of testing.
|
|
647
|
+
* @deprecated
|
|
648
|
+
*/
|
|
649
|
+
kFastTimer
|
|
650
|
+
};
|
|
523
651
|
}
|
|
524
652
|
});
|
|
525
653
|
|
|
526
|
-
// ../../node_modules/.pnpm/undici@
|
|
654
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/core/constants.js
|
|
527
655
|
var require_constants = __commonJS({
|
|
528
|
-
"../../node_modules/.pnpm/undici@
|
|
656
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/core/constants.js"(exports2, module2) {
|
|
529
657
|
"use strict";
|
|
658
|
+
var wellknownHeaderNames = (
|
|
659
|
+
/** @type {const} */
|
|
660
|
+
[
|
|
661
|
+
"Accept",
|
|
662
|
+
"Accept-Encoding",
|
|
663
|
+
"Accept-Language",
|
|
664
|
+
"Accept-Ranges",
|
|
665
|
+
"Access-Control-Allow-Credentials",
|
|
666
|
+
"Access-Control-Allow-Headers",
|
|
667
|
+
"Access-Control-Allow-Methods",
|
|
668
|
+
"Access-Control-Allow-Origin",
|
|
669
|
+
"Access-Control-Expose-Headers",
|
|
670
|
+
"Access-Control-Max-Age",
|
|
671
|
+
"Access-Control-Request-Headers",
|
|
672
|
+
"Access-Control-Request-Method",
|
|
673
|
+
"Age",
|
|
674
|
+
"Allow",
|
|
675
|
+
"Alt-Svc",
|
|
676
|
+
"Alt-Used",
|
|
677
|
+
"Authorization",
|
|
678
|
+
"Cache-Control",
|
|
679
|
+
"Clear-Site-Data",
|
|
680
|
+
"Connection",
|
|
681
|
+
"Content-Disposition",
|
|
682
|
+
"Content-Encoding",
|
|
683
|
+
"Content-Language",
|
|
684
|
+
"Content-Length",
|
|
685
|
+
"Content-Location",
|
|
686
|
+
"Content-Range",
|
|
687
|
+
"Content-Security-Policy",
|
|
688
|
+
"Content-Security-Policy-Report-Only",
|
|
689
|
+
"Content-Type",
|
|
690
|
+
"Cookie",
|
|
691
|
+
"Cross-Origin-Embedder-Policy",
|
|
692
|
+
"Cross-Origin-Opener-Policy",
|
|
693
|
+
"Cross-Origin-Resource-Policy",
|
|
694
|
+
"Date",
|
|
695
|
+
"Device-Memory",
|
|
696
|
+
"Downlink",
|
|
697
|
+
"ECT",
|
|
698
|
+
"ETag",
|
|
699
|
+
"Expect",
|
|
700
|
+
"Expect-CT",
|
|
701
|
+
"Expires",
|
|
702
|
+
"Forwarded",
|
|
703
|
+
"From",
|
|
704
|
+
"Host",
|
|
705
|
+
"If-Match",
|
|
706
|
+
"If-Modified-Since",
|
|
707
|
+
"If-None-Match",
|
|
708
|
+
"If-Range",
|
|
709
|
+
"If-Unmodified-Since",
|
|
710
|
+
"Keep-Alive",
|
|
711
|
+
"Last-Modified",
|
|
712
|
+
"Link",
|
|
713
|
+
"Location",
|
|
714
|
+
"Max-Forwards",
|
|
715
|
+
"Origin",
|
|
716
|
+
"Permissions-Policy",
|
|
717
|
+
"Pragma",
|
|
718
|
+
"Proxy-Authenticate",
|
|
719
|
+
"Proxy-Authorization",
|
|
720
|
+
"RTT",
|
|
721
|
+
"Range",
|
|
722
|
+
"Referer",
|
|
723
|
+
"Referrer-Policy",
|
|
724
|
+
"Refresh",
|
|
725
|
+
"Retry-After",
|
|
726
|
+
"Sec-WebSocket-Accept",
|
|
727
|
+
"Sec-WebSocket-Extensions",
|
|
728
|
+
"Sec-WebSocket-Key",
|
|
729
|
+
"Sec-WebSocket-Protocol",
|
|
730
|
+
"Sec-WebSocket-Version",
|
|
731
|
+
"Server",
|
|
732
|
+
"Server-Timing",
|
|
733
|
+
"Service-Worker-Allowed",
|
|
734
|
+
"Service-Worker-Navigation-Preload",
|
|
735
|
+
"Set-Cookie",
|
|
736
|
+
"SourceMap",
|
|
737
|
+
"Strict-Transport-Security",
|
|
738
|
+
"Supports-Loading-Mode",
|
|
739
|
+
"TE",
|
|
740
|
+
"Timing-Allow-Origin",
|
|
741
|
+
"Trailer",
|
|
742
|
+
"Transfer-Encoding",
|
|
743
|
+
"Upgrade",
|
|
744
|
+
"Upgrade-Insecure-Requests",
|
|
745
|
+
"User-Agent",
|
|
746
|
+
"Vary",
|
|
747
|
+
"Via",
|
|
748
|
+
"WWW-Authenticate",
|
|
749
|
+
"X-Content-Type-Options",
|
|
750
|
+
"X-DNS-Prefetch-Control",
|
|
751
|
+
"X-Frame-Options",
|
|
752
|
+
"X-Permitted-Cross-Domain-Policies",
|
|
753
|
+
"X-Powered-By",
|
|
754
|
+
"X-Requested-With",
|
|
755
|
+
"X-XSS-Protection"
|
|
756
|
+
]
|
|
757
|
+
);
|
|
530
758
|
var headerNameLowerCasedRecord = {};
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
"Access-Control-Max-Age",
|
|
542
|
-
"Access-Control-Request-Headers",
|
|
543
|
-
"Access-Control-Request-Method",
|
|
544
|
-
"Age",
|
|
545
|
-
"Allow",
|
|
546
|
-
"Alt-Svc",
|
|
547
|
-
"Alt-Used",
|
|
548
|
-
"Authorization",
|
|
549
|
-
"Cache-Control",
|
|
550
|
-
"Clear-Site-Data",
|
|
551
|
-
"Connection",
|
|
552
|
-
"Content-Disposition",
|
|
553
|
-
"Content-Encoding",
|
|
554
|
-
"Content-Language",
|
|
555
|
-
"Content-Length",
|
|
556
|
-
"Content-Location",
|
|
557
|
-
"Content-Range",
|
|
558
|
-
"Content-Security-Policy",
|
|
559
|
-
"Content-Security-Policy-Report-Only",
|
|
560
|
-
"Content-Type",
|
|
561
|
-
"Cookie",
|
|
562
|
-
"Cross-Origin-Embedder-Policy",
|
|
563
|
-
"Cross-Origin-Opener-Policy",
|
|
564
|
-
"Cross-Origin-Resource-Policy",
|
|
565
|
-
"Date",
|
|
566
|
-
"Device-Memory",
|
|
567
|
-
"Downlink",
|
|
568
|
-
"ECT",
|
|
569
|
-
"ETag",
|
|
570
|
-
"Expect",
|
|
571
|
-
"Expect-CT",
|
|
572
|
-
"Expires",
|
|
573
|
-
"Forwarded",
|
|
574
|
-
"From",
|
|
575
|
-
"Host",
|
|
576
|
-
"If-Match",
|
|
577
|
-
"If-Modified-Since",
|
|
578
|
-
"If-None-Match",
|
|
579
|
-
"If-Range",
|
|
580
|
-
"If-Unmodified-Since",
|
|
581
|
-
"Keep-Alive",
|
|
582
|
-
"Last-Modified",
|
|
583
|
-
"Link",
|
|
584
|
-
"Location",
|
|
585
|
-
"Max-Forwards",
|
|
586
|
-
"Origin",
|
|
587
|
-
"Permissions-Policy",
|
|
588
|
-
"Pragma",
|
|
589
|
-
"Proxy-Authenticate",
|
|
590
|
-
"Proxy-Authorization",
|
|
591
|
-
"RTT",
|
|
592
|
-
"Range",
|
|
593
|
-
"Referer",
|
|
594
|
-
"Referrer-Policy",
|
|
595
|
-
"Refresh",
|
|
596
|
-
"Retry-After",
|
|
597
|
-
"Sec-WebSocket-Accept",
|
|
598
|
-
"Sec-WebSocket-Extensions",
|
|
599
|
-
"Sec-WebSocket-Key",
|
|
600
|
-
"Sec-WebSocket-Protocol",
|
|
601
|
-
"Sec-WebSocket-Version",
|
|
602
|
-
"Server",
|
|
603
|
-
"Server-Timing",
|
|
604
|
-
"Service-Worker-Allowed",
|
|
605
|
-
"Service-Worker-Navigation-Preload",
|
|
606
|
-
"Set-Cookie",
|
|
607
|
-
"SourceMap",
|
|
608
|
-
"Strict-Transport-Security",
|
|
609
|
-
"Supports-Loading-Mode",
|
|
610
|
-
"TE",
|
|
611
|
-
"Timing-Allow-Origin",
|
|
612
|
-
"Trailer",
|
|
613
|
-
"Transfer-Encoding",
|
|
614
|
-
"Upgrade",
|
|
615
|
-
"Upgrade-Insecure-Requests",
|
|
616
|
-
"User-Agent",
|
|
617
|
-
"Vary",
|
|
618
|
-
"Via",
|
|
619
|
-
"WWW-Authenticate",
|
|
620
|
-
"X-Content-Type-Options",
|
|
621
|
-
"X-DNS-Prefetch-Control",
|
|
622
|
-
"X-Frame-Options",
|
|
623
|
-
"X-Permitted-Cross-Domain-Policies",
|
|
624
|
-
"X-Powered-By",
|
|
625
|
-
"X-Requested-With",
|
|
626
|
-
"X-XSS-Protection"
|
|
627
|
-
];
|
|
759
|
+
Object.setPrototypeOf(headerNameLowerCasedRecord, null);
|
|
760
|
+
var wellknownHeaderNameBuffers = {};
|
|
761
|
+
Object.setPrototypeOf(wellknownHeaderNameBuffers, null);
|
|
762
|
+
function getHeaderNameAsBuffer(header) {
|
|
763
|
+
let buffer = wellknownHeaderNameBuffers[header];
|
|
764
|
+
if (buffer === void 0) {
|
|
765
|
+
buffer = Buffer.from(header);
|
|
766
|
+
}
|
|
767
|
+
return buffer;
|
|
768
|
+
}
|
|
628
769
|
for (let i = 0; i < wellknownHeaderNames.length; ++i) {
|
|
629
770
|
const key = wellknownHeaderNames[i];
|
|
630
771
|
const lowerCasedKey = key.toLowerCase();
|
|
631
772
|
headerNameLowerCasedRecord[key] = headerNameLowerCasedRecord[lowerCasedKey] = lowerCasedKey;
|
|
632
773
|
}
|
|
633
|
-
Object.setPrototypeOf(headerNameLowerCasedRecord, null);
|
|
634
774
|
module2.exports = {
|
|
775
|
+
wellknownHeaderNames,
|
|
776
|
+
headerNameLowerCasedRecord,
|
|
777
|
+
getHeaderNameAsBuffer
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/core/tree.js
|
|
783
|
+
var require_tree = __commonJS({
|
|
784
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/core/tree.js"(exports2, module2) {
|
|
785
|
+
"use strict";
|
|
786
|
+
var {
|
|
635
787
|
wellknownHeaderNames,
|
|
636
788
|
headerNameLowerCasedRecord
|
|
789
|
+
} = require_constants();
|
|
790
|
+
var TstNode = class _TstNode {
|
|
791
|
+
/** @type {any} */
|
|
792
|
+
value = null;
|
|
793
|
+
/** @type {null | TstNode} */
|
|
794
|
+
left = null;
|
|
795
|
+
/** @type {null | TstNode} */
|
|
796
|
+
middle = null;
|
|
797
|
+
/** @type {null | TstNode} */
|
|
798
|
+
right = null;
|
|
799
|
+
/** @type {number} */
|
|
800
|
+
code;
|
|
801
|
+
/**
|
|
802
|
+
* @param {string} key
|
|
803
|
+
* @param {any} value
|
|
804
|
+
* @param {number} index
|
|
805
|
+
*/
|
|
806
|
+
constructor(key, value, index) {
|
|
807
|
+
if (index === void 0 || index >= key.length) {
|
|
808
|
+
throw new TypeError("Unreachable");
|
|
809
|
+
}
|
|
810
|
+
const code = this.code = key.charCodeAt(index);
|
|
811
|
+
if (code > 127) {
|
|
812
|
+
throw new TypeError("key must be ascii string");
|
|
813
|
+
}
|
|
814
|
+
if (key.length !== ++index) {
|
|
815
|
+
this.middle = new _TstNode(key, value, index);
|
|
816
|
+
} else {
|
|
817
|
+
this.value = value;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* @param {string} key
|
|
822
|
+
* @param {any} value
|
|
823
|
+
* @returns {void}
|
|
824
|
+
*/
|
|
825
|
+
add(key, value) {
|
|
826
|
+
const length = key.length;
|
|
827
|
+
if (length === 0) {
|
|
828
|
+
throw new TypeError("Unreachable");
|
|
829
|
+
}
|
|
830
|
+
let index = 0;
|
|
831
|
+
let node = this;
|
|
832
|
+
while (true) {
|
|
833
|
+
const code = key.charCodeAt(index);
|
|
834
|
+
if (code > 127) {
|
|
835
|
+
throw new TypeError("key must be ascii string");
|
|
836
|
+
}
|
|
837
|
+
if (node.code === code) {
|
|
838
|
+
if (length === ++index) {
|
|
839
|
+
node.value = value;
|
|
840
|
+
break;
|
|
841
|
+
} else if (node.middle !== null) {
|
|
842
|
+
node = node.middle;
|
|
843
|
+
} else {
|
|
844
|
+
node.middle = new _TstNode(key, value, index);
|
|
845
|
+
break;
|
|
846
|
+
}
|
|
847
|
+
} else if (node.code < code) {
|
|
848
|
+
if (node.left !== null) {
|
|
849
|
+
node = node.left;
|
|
850
|
+
} else {
|
|
851
|
+
node.left = new _TstNode(key, value, index);
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
854
|
+
} else if (node.right !== null) {
|
|
855
|
+
node = node.right;
|
|
856
|
+
} else {
|
|
857
|
+
node.right = new _TstNode(key, value, index);
|
|
858
|
+
break;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* @param {Uint8Array} key
|
|
864
|
+
* @return {TstNode | null}
|
|
865
|
+
*/
|
|
866
|
+
search(key) {
|
|
867
|
+
const keylength = key.length;
|
|
868
|
+
let index = 0;
|
|
869
|
+
let node = this;
|
|
870
|
+
while (node !== null && index < keylength) {
|
|
871
|
+
let code = key[index];
|
|
872
|
+
if (code <= 90 && code >= 65) {
|
|
873
|
+
code |= 32;
|
|
874
|
+
}
|
|
875
|
+
while (node !== null) {
|
|
876
|
+
if (code === node.code) {
|
|
877
|
+
if (keylength === ++index) {
|
|
878
|
+
return node;
|
|
879
|
+
}
|
|
880
|
+
node = node.middle;
|
|
881
|
+
break;
|
|
882
|
+
}
|
|
883
|
+
node = node.code < code ? node.left : node.right;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
return null;
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
var TernarySearchTree = class {
|
|
890
|
+
/** @type {TstNode | null} */
|
|
891
|
+
node = null;
|
|
892
|
+
/**
|
|
893
|
+
* @param {string} key
|
|
894
|
+
* @param {any} value
|
|
895
|
+
* @returns {void}
|
|
896
|
+
* */
|
|
897
|
+
insert(key, value) {
|
|
898
|
+
if (this.node === null) {
|
|
899
|
+
this.node = new TstNode(key, value, 0);
|
|
900
|
+
} else {
|
|
901
|
+
this.node.add(key, value);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* @param {Uint8Array} key
|
|
906
|
+
* @returns {any}
|
|
907
|
+
*/
|
|
908
|
+
lookup(key) {
|
|
909
|
+
return this.node?.search(key)?.value ?? null;
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
var tree = new TernarySearchTree();
|
|
913
|
+
for (let i = 0; i < wellknownHeaderNames.length; ++i) {
|
|
914
|
+
const key = headerNameLowerCasedRecord[wellknownHeaderNames[i]];
|
|
915
|
+
tree.insert(key, key);
|
|
916
|
+
}
|
|
917
|
+
module2.exports = {
|
|
918
|
+
TernarySearchTree,
|
|
919
|
+
tree
|
|
637
920
|
};
|
|
638
921
|
}
|
|
639
922
|
});
|
|
640
923
|
|
|
641
|
-
// ../../node_modules/.pnpm/undici@
|
|
924
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/core/util.js
|
|
642
925
|
var require_util = __commonJS({
|
|
643
|
-
"../../node_modules/.pnpm/undici@
|
|
926
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/core/util.js"(exports2, module2) {
|
|
644
927
|
"use strict";
|
|
645
|
-
var assert = require("assert");
|
|
646
|
-
var { kDestroyed, kBodyUsed } = require_symbols();
|
|
647
|
-
var { IncomingMessage } = require("http");
|
|
648
|
-
var stream = require("stream");
|
|
649
|
-
var net = require("net");
|
|
650
|
-
var {
|
|
651
|
-
var {
|
|
652
|
-
var
|
|
653
|
-
var
|
|
928
|
+
var assert = require("node:assert");
|
|
929
|
+
var { kDestroyed, kBodyUsed, kListeners, kBody } = require_symbols();
|
|
930
|
+
var { IncomingMessage } = require("node:http");
|
|
931
|
+
var stream = require("node:stream");
|
|
932
|
+
var net = require("node:net");
|
|
933
|
+
var { Blob } = require("node:buffer");
|
|
934
|
+
var { stringify } = require("node:querystring");
|
|
935
|
+
var { EventEmitter: EE } = require("node:events");
|
|
936
|
+
var timers = require_timers();
|
|
937
|
+
var { InvalidArgumentError, ConnectTimeoutError } = require_errors();
|
|
654
938
|
var { headerNameLowerCasedRecord } = require_constants();
|
|
655
|
-
var
|
|
656
|
-
|
|
939
|
+
var { tree } = require_tree();
|
|
940
|
+
var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v));
|
|
941
|
+
var BodyAsyncIterable = class {
|
|
942
|
+
constructor(body) {
|
|
943
|
+
this[kBody] = body;
|
|
944
|
+
this[kBodyUsed] = false;
|
|
945
|
+
}
|
|
946
|
+
async *[Symbol.asyncIterator]() {
|
|
947
|
+
assert(!this[kBodyUsed], "disturbed");
|
|
948
|
+
this[kBodyUsed] = true;
|
|
949
|
+
yield* this[kBody];
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
function noop() {
|
|
953
|
+
}
|
|
954
|
+
function wrapRequestBody(body) {
|
|
955
|
+
if (isStream(body)) {
|
|
956
|
+
if (bodyLength(body) === 0) {
|
|
957
|
+
body.on("data", function() {
|
|
958
|
+
assert(false);
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
if (typeof body.readableDidRead !== "boolean") {
|
|
962
|
+
body[kBodyUsed] = false;
|
|
963
|
+
EE.prototype.on.call(body, "data", function() {
|
|
964
|
+
this[kBodyUsed] = true;
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
return body;
|
|
968
|
+
} else if (body && typeof body.pipeTo === "function") {
|
|
969
|
+
return new BodyAsyncIterable(body);
|
|
970
|
+
} else if (body && typeof body !== "string" && !ArrayBuffer.isView(body) && isIterable(body)) {
|
|
971
|
+
return new BodyAsyncIterable(body);
|
|
972
|
+
} else {
|
|
973
|
+
return body;
|
|
974
|
+
}
|
|
657
975
|
}
|
|
658
976
|
function isStream(obj) {
|
|
659
977
|
return obj && typeof obj === "object" && typeof obj.pipe === "function" && typeof obj.on === "function";
|
|
660
978
|
}
|
|
661
979
|
function isBlobLike(object) {
|
|
662
|
-
|
|
980
|
+
if (object === null) {
|
|
981
|
+
return false;
|
|
982
|
+
} else if (object instanceof Blob) {
|
|
983
|
+
return true;
|
|
984
|
+
} else if (typeof object !== "object") {
|
|
985
|
+
return false;
|
|
986
|
+
} else {
|
|
987
|
+
const sTag = object[Symbol.toStringTag];
|
|
988
|
+
return (sTag === "Blob" || sTag === "File") && ("stream" in object && typeof object.stream === "function" || "arrayBuffer" in object && typeof object.arrayBuffer === "function");
|
|
989
|
+
}
|
|
663
990
|
}
|
|
664
|
-
function
|
|
991
|
+
function serializePathWithQuery(url, queryParams) {
|
|
665
992
|
if (url.includes("?") || url.includes("#")) {
|
|
666
993
|
throw new Error('Query params cannot be passed when url already contains "?" or "#".');
|
|
667
994
|
}
|
|
@@ -671,10 +998,17 @@ var require_util = __commonJS({
|
|
|
671
998
|
}
|
|
672
999
|
return url;
|
|
673
1000
|
}
|
|
1001
|
+
function isValidPort(port) {
|
|
1002
|
+
const value = parseInt(port, 10);
|
|
1003
|
+
return value === Number(port) && value >= 0 && value <= 65535;
|
|
1004
|
+
}
|
|
1005
|
+
function isHttpOrHttpsPrefixed(value) {
|
|
1006
|
+
return value != null && value[0] === "h" && value[1] === "t" && value[2] === "t" && value[3] === "p" && (value[4] === ":" || value[4] === "s" && value[5] === ":");
|
|
1007
|
+
}
|
|
674
1008
|
function parseURL(url) {
|
|
675
1009
|
if (typeof url === "string") {
|
|
676
1010
|
url = new URL(url);
|
|
677
|
-
if (
|
|
1011
|
+
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
|
|
678
1012
|
throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
679
1013
|
}
|
|
680
1014
|
return url;
|
|
@@ -682,11 +1016,8 @@ var require_util = __commonJS({
|
|
|
682
1016
|
if (!url || typeof url !== "object") {
|
|
683
1017
|
throw new InvalidArgumentError("Invalid URL: The URL argument must be a non-null object.");
|
|
684
1018
|
}
|
|
685
|
-
if (!/^https?:/.test(url.origin || url.protocol)) {
|
|
686
|
-
throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
687
|
-
}
|
|
688
1019
|
if (!(url instanceof URL)) {
|
|
689
|
-
if (url.port != null && url.port !== "" &&
|
|
1020
|
+
if (url.port != null && url.port !== "" && isValidPort(url.port) === false) {
|
|
690
1021
|
throw new InvalidArgumentError("Invalid URL: port must be a valid integer or a string representation of an integer.");
|
|
691
1022
|
}
|
|
692
1023
|
if (url.path != null && typeof url.path !== "string") {
|
|
@@ -701,16 +1032,22 @@ var require_util = __commonJS({
|
|
|
701
1032
|
if (url.origin != null && typeof url.origin !== "string") {
|
|
702
1033
|
throw new InvalidArgumentError("Invalid URL origin: the origin must be a string or null/undefined.");
|
|
703
1034
|
}
|
|
1035
|
+
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
|
|
1036
|
+
throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
1037
|
+
}
|
|
704
1038
|
const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
|
|
705
|
-
let origin = url.origin != null ? url.origin : `${url.protocol}//${url.hostname}:${port}`;
|
|
1039
|
+
let origin = url.origin != null ? url.origin : `${url.protocol || ""}//${url.hostname || ""}:${port}`;
|
|
706
1040
|
let path = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
|
|
707
|
-
if (origin.
|
|
708
|
-
origin = origin.
|
|
1041
|
+
if (origin[origin.length - 1] === "/") {
|
|
1042
|
+
origin = origin.slice(0, origin.length - 1);
|
|
709
1043
|
}
|
|
710
|
-
if (path &&
|
|
1044
|
+
if (path && path[0] !== "/") {
|
|
711
1045
|
path = `/${path}`;
|
|
712
1046
|
}
|
|
713
|
-
|
|
1047
|
+
return new URL(`${origin}${path}`);
|
|
1048
|
+
}
|
|
1049
|
+
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
|
|
1050
|
+
throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
714
1051
|
}
|
|
715
1052
|
return url;
|
|
716
1053
|
}
|
|
@@ -735,7 +1072,7 @@ var require_util = __commonJS({
|
|
|
735
1072
|
if (!host) {
|
|
736
1073
|
return null;
|
|
737
1074
|
}
|
|
738
|
-
assert
|
|
1075
|
+
assert(typeof host === "string");
|
|
739
1076
|
const servername = getHostname(host);
|
|
740
1077
|
if (net.isIP(servername)) {
|
|
741
1078
|
return "";
|
|
@@ -764,12 +1101,8 @@ var require_util = __commonJS({
|
|
|
764
1101
|
}
|
|
765
1102
|
return null;
|
|
766
1103
|
}
|
|
767
|
-
function isDestroyed(
|
|
768
|
-
return
|
|
769
|
-
}
|
|
770
|
-
function isReadableAborted(stream2) {
|
|
771
|
-
const state = stream2 && stream2._readableState;
|
|
772
|
-
return isDestroyed(stream2) && state && !state.endEmitted;
|
|
1104
|
+
function isDestroyed(body) {
|
|
1105
|
+
return body && !!(body.destroyed || body[kDestroyed] || stream.isDestroyed?.(body));
|
|
773
1106
|
}
|
|
774
1107
|
function destroy(stream2, err) {
|
|
775
1108
|
if (stream2 == null || !isStream(stream2) || isDestroyed(stream2)) {
|
|
@@ -781,9 +1114,9 @@ var require_util = __commonJS({
|
|
|
781
1114
|
}
|
|
782
1115
|
stream2.destroy(err);
|
|
783
1116
|
} else if (err) {
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
}
|
|
1117
|
+
queueMicrotask(() => {
|
|
1118
|
+
stream2.emit("error", err);
|
|
1119
|
+
});
|
|
787
1120
|
}
|
|
788
1121
|
if (stream2.destroyed !== true) {
|
|
789
1122
|
stream2[kDestroyed] = true;
|
|
@@ -791,29 +1124,33 @@ var require_util = __commonJS({
|
|
|
791
1124
|
}
|
|
792
1125
|
var KEEPALIVE_TIMEOUT_EXPR = /timeout=(\d+)/;
|
|
793
1126
|
function parseKeepAliveTimeout(val) {
|
|
794
|
-
const m = val.
|
|
1127
|
+
const m = val.match(KEEPALIVE_TIMEOUT_EXPR);
|
|
795
1128
|
return m ? parseInt(m[1], 10) * 1e3 : null;
|
|
796
1129
|
}
|
|
797
1130
|
function headerNameToString(value) {
|
|
798
|
-
return headerNameLowerCasedRecord[value]
|
|
1131
|
+
return typeof value === "string" ? headerNameLowerCasedRecord[value] ?? value.toLowerCase() : tree.lookup(value) ?? value.toString("latin1").toLowerCase();
|
|
799
1132
|
}
|
|
800
|
-
function
|
|
801
|
-
|
|
1133
|
+
function bufferToLowerCasedHeaderName(value) {
|
|
1134
|
+
return tree.lookup(value) ?? value.toString("latin1").toLowerCase();
|
|
1135
|
+
}
|
|
1136
|
+
function parseHeaders(headers, obj) {
|
|
1137
|
+
if (obj === void 0) obj = {};
|
|
802
1138
|
for (let i = 0; i < headers.length; i += 2) {
|
|
803
|
-
const key = headers[i]
|
|
1139
|
+
const key = headerNameToString(headers[i]);
|
|
804
1140
|
let val = obj[key];
|
|
805
|
-
if (
|
|
806
|
-
if (
|
|
807
|
-
obj[key] = headers[i + 1].map((x) => x.toString("utf8"));
|
|
808
|
-
} else {
|
|
809
|
-
obj[key] = headers[i + 1].toString("utf8");
|
|
810
|
-
}
|
|
811
|
-
} else {
|
|
812
|
-
if (!Array.isArray(val)) {
|
|
1141
|
+
if (val) {
|
|
1142
|
+
if (typeof val === "string") {
|
|
813
1143
|
val = [val];
|
|
814
1144
|
obj[key] = val;
|
|
815
1145
|
}
|
|
816
1146
|
val.push(headers[i + 1].toString("utf8"));
|
|
1147
|
+
} else {
|
|
1148
|
+
const headersValue = headers[i + 1];
|
|
1149
|
+
if (typeof headersValue === "string") {
|
|
1150
|
+
obj[key] = headersValue;
|
|
1151
|
+
} else {
|
|
1152
|
+
obj[key] = Array.isArray(headersValue) ? headersValue.map((x) => x.toString("utf8")) : headersValue.toString("utf8");
|
|
1153
|
+
}
|
|
817
1154
|
}
|
|
818
1155
|
}
|
|
819
1156
|
if ("content-length" in obj && "content-disposition" in obj) {
|
|
@@ -822,33 +1159,48 @@ var require_util = __commonJS({
|
|
|
822
1159
|
return obj;
|
|
823
1160
|
}
|
|
824
1161
|
function parseRawHeaders(headers) {
|
|
825
|
-
const
|
|
1162
|
+
const headersLength = headers.length;
|
|
1163
|
+
const ret = new Array(headersLength);
|
|
826
1164
|
let hasContentLength = false;
|
|
827
1165
|
let contentDispositionIdx = -1;
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
1166
|
+
let key;
|
|
1167
|
+
let val;
|
|
1168
|
+
let kLen = 0;
|
|
1169
|
+
for (let n = 0; n < headersLength; n += 2) {
|
|
1170
|
+
key = headers[n];
|
|
1171
|
+
val = headers[n + 1];
|
|
1172
|
+
typeof key !== "string" && (key = key.toString());
|
|
1173
|
+
typeof val !== "string" && (val = val.toString("utf8"));
|
|
1174
|
+
kLen = key.length;
|
|
1175
|
+
if (kLen === 14 && key[7] === "-" && (key === "content-length" || key.toLowerCase() === "content-length")) {
|
|
833
1176
|
hasContentLength = true;
|
|
834
|
-
} else if (
|
|
835
|
-
contentDispositionIdx =
|
|
836
|
-
} else {
|
|
837
|
-
ret.push(key, val);
|
|
1177
|
+
} else if (kLen === 19 && key[7] === "-" && (key === "content-disposition" || key.toLowerCase() === "content-disposition")) {
|
|
1178
|
+
contentDispositionIdx = n + 1;
|
|
838
1179
|
}
|
|
1180
|
+
ret[n] = key;
|
|
1181
|
+
ret[n + 1] = val;
|
|
839
1182
|
}
|
|
840
1183
|
if (hasContentLength && contentDispositionIdx !== -1) {
|
|
841
1184
|
ret[contentDispositionIdx] = Buffer.from(ret[contentDispositionIdx]).toString("latin1");
|
|
842
1185
|
}
|
|
843
1186
|
return ret;
|
|
844
1187
|
}
|
|
1188
|
+
function encodeRawHeaders(headers) {
|
|
1189
|
+
if (!Array.isArray(headers)) {
|
|
1190
|
+
throw new TypeError("expected headers to be an array");
|
|
1191
|
+
}
|
|
1192
|
+
return headers.map((x) => Buffer.from(x));
|
|
1193
|
+
}
|
|
845
1194
|
function isBuffer(buffer) {
|
|
846
1195
|
return buffer instanceof Uint8Array || Buffer.isBuffer(buffer);
|
|
847
1196
|
}
|
|
848
|
-
function
|
|
1197
|
+
function assertRequestHandler(handler, method, upgrade) {
|
|
849
1198
|
if (!handler || typeof handler !== "object") {
|
|
850
1199
|
throw new InvalidArgumentError("handler must be an object");
|
|
851
1200
|
}
|
|
1201
|
+
if (typeof handler.onRequestStart === "function") {
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
852
1204
|
if (typeof handler.onConnect !== "function") {
|
|
853
1205
|
throw new InvalidArgumentError("invalid onConnect method");
|
|
854
1206
|
}
|
|
@@ -875,17 +1227,7 @@ var require_util = __commonJS({
|
|
|
875
1227
|
}
|
|
876
1228
|
}
|
|
877
1229
|
function isDisturbed(body) {
|
|
878
|
-
return !!(body && (stream.isDisturbed
|
|
879
|
-
}
|
|
880
|
-
function isErrored(body) {
|
|
881
|
-
return !!(body && (stream.isErrored ? stream.isErrored(body) : /state: 'errored'/.test(
|
|
882
|
-
nodeUtil.inspect(body)
|
|
883
|
-
)));
|
|
884
|
-
}
|
|
885
|
-
function isReadable(body) {
|
|
886
|
-
return !!(body && (stream.isReadable ? stream.isReadable(body) : /state: 'readable'/.test(
|
|
887
|
-
nodeUtil.inspect(body)
|
|
888
|
-
)));
|
|
1230
|
+
return !!(body && (stream.isDisturbed(body) || body[kBodyUsed]));
|
|
889
1231
|
}
|
|
890
1232
|
function getSocketInfo(socket) {
|
|
891
1233
|
return {
|
|
@@ -899,97 +1241,192 @@ var require_util = __commonJS({
|
|
|
899
1241
|
bytesRead: socket.bytesRead
|
|
900
1242
|
};
|
|
901
1243
|
}
|
|
902
|
-
async function* convertIterableToBuffer(iterable) {
|
|
903
|
-
for await (const chunk of iterable) {
|
|
904
|
-
yield Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
var ReadableStream;
|
|
908
1244
|
function ReadableStreamFrom(iterable) {
|
|
909
|
-
if (!ReadableStream) {
|
|
910
|
-
ReadableStream = require("stream/web").ReadableStream;
|
|
911
|
-
}
|
|
912
|
-
if (ReadableStream.from) {
|
|
913
|
-
return ReadableStream.from(convertIterableToBuffer(iterable));
|
|
914
|
-
}
|
|
915
1245
|
let iterator;
|
|
916
1246
|
return new ReadableStream(
|
|
917
1247
|
{
|
|
918
1248
|
async start() {
|
|
919
1249
|
iterator = iterable[Symbol.asyncIterator]();
|
|
920
1250
|
},
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1251
|
+
pull(controller) {
|
|
1252
|
+
async function pull() {
|
|
1253
|
+
const { done, value } = await iterator.next();
|
|
1254
|
+
if (done) {
|
|
1255
|
+
queueMicrotask(() => {
|
|
1256
|
+
controller.close();
|
|
1257
|
+
controller.byobRequest?.respond(0);
|
|
1258
|
+
});
|
|
1259
|
+
} else {
|
|
1260
|
+
const buf = Buffer.isBuffer(value) ? value : Buffer.from(value);
|
|
1261
|
+
if (buf.byteLength) {
|
|
1262
|
+
controller.enqueue(new Uint8Array(buf));
|
|
1263
|
+
} else {
|
|
1264
|
+
return await pull();
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
930
1267
|
}
|
|
931
|
-
return
|
|
1268
|
+
return pull();
|
|
932
1269
|
},
|
|
933
|
-
async cancel(
|
|
1270
|
+
async cancel() {
|
|
934
1271
|
await iterator.return();
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
|
|
1272
|
+
},
|
|
1273
|
+
type: "bytes"
|
|
1274
|
+
}
|
|
938
1275
|
);
|
|
939
1276
|
}
|
|
940
1277
|
function isFormDataLike(object) {
|
|
941
1278
|
return object && typeof object === "object" && typeof object.append === "function" && typeof object.delete === "function" && typeof object.get === "function" && typeof object.getAll === "function" && typeof object.has === "function" && typeof object.set === "function" && object[Symbol.toStringTag] === "FormData";
|
|
942
1279
|
}
|
|
943
|
-
function throwIfAborted(signal) {
|
|
944
|
-
if (!signal) {
|
|
945
|
-
return;
|
|
946
|
-
}
|
|
947
|
-
if (typeof signal.throwIfAborted === "function") {
|
|
948
|
-
signal.throwIfAborted();
|
|
949
|
-
} else {
|
|
950
|
-
if (signal.aborted) {
|
|
951
|
-
const err = new Error("The operation was aborted");
|
|
952
|
-
err.name = "AbortError";
|
|
953
|
-
throw err;
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
1280
|
function addAbortListener(signal, listener) {
|
|
958
1281
|
if ("addEventListener" in signal) {
|
|
959
1282
|
signal.addEventListener("abort", listener, { once: true });
|
|
960
1283
|
return () => signal.removeEventListener("abort", listener);
|
|
961
1284
|
}
|
|
962
|
-
signal.
|
|
1285
|
+
signal.once("abort", listener);
|
|
963
1286
|
return () => signal.removeListener("abort", listener);
|
|
964
1287
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
1288
|
+
function isTokenCharCode(c) {
|
|
1289
|
+
switch (c) {
|
|
1290
|
+
case 34:
|
|
1291
|
+
case 40:
|
|
1292
|
+
case 41:
|
|
1293
|
+
case 44:
|
|
1294
|
+
case 47:
|
|
1295
|
+
case 58:
|
|
1296
|
+
case 59:
|
|
1297
|
+
case 60:
|
|
1298
|
+
case 61:
|
|
1299
|
+
case 62:
|
|
1300
|
+
case 63:
|
|
1301
|
+
case 64:
|
|
1302
|
+
case 91:
|
|
1303
|
+
case 92:
|
|
1304
|
+
case 93:
|
|
1305
|
+
case 123:
|
|
1306
|
+
case 125:
|
|
1307
|
+
return false;
|
|
1308
|
+
default:
|
|
1309
|
+
return c >= 33 && c <= 126;
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
function isValidHTTPToken(characters) {
|
|
1313
|
+
if (characters.length === 0) {
|
|
1314
|
+
return false;
|
|
971
1315
|
}
|
|
972
|
-
|
|
1316
|
+
for (let i = 0; i < characters.length; ++i) {
|
|
1317
|
+
if (!isTokenCharCode(characters.charCodeAt(i))) {
|
|
1318
|
+
return false;
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
return true;
|
|
973
1322
|
}
|
|
1323
|
+
var headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
|
|
1324
|
+
function isValidHeaderValue(characters) {
|
|
1325
|
+
return !headerCharRegex.test(characters);
|
|
1326
|
+
}
|
|
1327
|
+
var rangeHeaderRegex = /^bytes (\d+)-(\d+)\/(\d+)?$/;
|
|
974
1328
|
function parseRangeHeader(range) {
|
|
975
1329
|
if (range == null || range === "") return { start: 0, end: null, size: null };
|
|
976
|
-
const m = range ? range.match(
|
|
1330
|
+
const m = range ? range.match(rangeHeaderRegex) : null;
|
|
977
1331
|
return m ? {
|
|
978
1332
|
start: parseInt(m[1]),
|
|
979
1333
|
end: m[2] ? parseInt(m[2]) : null,
|
|
980
1334
|
size: m[3] ? parseInt(m[3]) : null
|
|
981
1335
|
} : null;
|
|
982
1336
|
}
|
|
1337
|
+
function addListener(obj, name, listener) {
|
|
1338
|
+
const listeners = obj[kListeners] ??= [];
|
|
1339
|
+
listeners.push([name, listener]);
|
|
1340
|
+
obj.on(name, listener);
|
|
1341
|
+
return obj;
|
|
1342
|
+
}
|
|
1343
|
+
function removeAllListeners(obj) {
|
|
1344
|
+
if (obj[kListeners] != null) {
|
|
1345
|
+
for (const [name, listener] of obj[kListeners]) {
|
|
1346
|
+
obj.removeListener(name, listener);
|
|
1347
|
+
}
|
|
1348
|
+
obj[kListeners] = null;
|
|
1349
|
+
}
|
|
1350
|
+
return obj;
|
|
1351
|
+
}
|
|
1352
|
+
function errorRequest(client, request, err) {
|
|
1353
|
+
try {
|
|
1354
|
+
request.onError(err);
|
|
1355
|
+
assert(request.aborted);
|
|
1356
|
+
} catch (err2) {
|
|
1357
|
+
client.emit("error", err2);
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => {
|
|
1361
|
+
if (!opts.timeout) {
|
|
1362
|
+
return noop;
|
|
1363
|
+
}
|
|
1364
|
+
let s1 = null;
|
|
1365
|
+
let s2 = null;
|
|
1366
|
+
const fastTimer = timers.setFastTimeout(() => {
|
|
1367
|
+
s1 = setImmediate(() => {
|
|
1368
|
+
s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts));
|
|
1369
|
+
});
|
|
1370
|
+
}, opts.timeout);
|
|
1371
|
+
return () => {
|
|
1372
|
+
timers.clearFastTimeout(fastTimer);
|
|
1373
|
+
clearImmediate(s1);
|
|
1374
|
+
clearImmediate(s2);
|
|
1375
|
+
};
|
|
1376
|
+
} : (socketWeakRef, opts) => {
|
|
1377
|
+
if (!opts.timeout) {
|
|
1378
|
+
return noop;
|
|
1379
|
+
}
|
|
1380
|
+
let s1 = null;
|
|
1381
|
+
const fastTimer = timers.setFastTimeout(() => {
|
|
1382
|
+
s1 = setImmediate(() => {
|
|
1383
|
+
onConnectTimeout(socketWeakRef.deref(), opts);
|
|
1384
|
+
});
|
|
1385
|
+
}, opts.timeout);
|
|
1386
|
+
return () => {
|
|
1387
|
+
timers.clearFastTimeout(fastTimer);
|
|
1388
|
+
clearImmediate(s1);
|
|
1389
|
+
};
|
|
1390
|
+
};
|
|
1391
|
+
function onConnectTimeout(socket, opts) {
|
|
1392
|
+
if (socket == null) {
|
|
1393
|
+
return;
|
|
1394
|
+
}
|
|
1395
|
+
let message = "Connect Timeout Error";
|
|
1396
|
+
if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) {
|
|
1397
|
+
message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`;
|
|
1398
|
+
} else {
|
|
1399
|
+
message += ` (attempted address: ${opts.hostname}:${opts.port},`;
|
|
1400
|
+
}
|
|
1401
|
+
message += ` timeout: ${opts.timeout}ms)`;
|
|
1402
|
+
destroy(socket, new ConnectTimeoutError(message));
|
|
1403
|
+
}
|
|
983
1404
|
var kEnumerableProperty = /* @__PURE__ */ Object.create(null);
|
|
984
1405
|
kEnumerableProperty.enumerable = true;
|
|
1406
|
+
var normalizedMethodRecordsBase = {
|
|
1407
|
+
delete: "DELETE",
|
|
1408
|
+
DELETE: "DELETE",
|
|
1409
|
+
get: "GET",
|
|
1410
|
+
GET: "GET",
|
|
1411
|
+
head: "HEAD",
|
|
1412
|
+
HEAD: "HEAD",
|
|
1413
|
+
options: "OPTIONS",
|
|
1414
|
+
OPTIONS: "OPTIONS",
|
|
1415
|
+
post: "POST",
|
|
1416
|
+
POST: "POST",
|
|
1417
|
+
put: "PUT",
|
|
1418
|
+
PUT: "PUT"
|
|
1419
|
+
};
|
|
1420
|
+
var normalizedMethodRecords = {
|
|
1421
|
+
...normalizedMethodRecordsBase,
|
|
1422
|
+
patch: "patch",
|
|
1423
|
+
PATCH: "PATCH"
|
|
1424
|
+
};
|
|
1425
|
+
Object.setPrototypeOf(normalizedMethodRecordsBase, null);
|
|
1426
|
+
Object.setPrototypeOf(normalizedMethodRecords, null);
|
|
985
1427
|
module2.exports = {
|
|
986
1428
|
kEnumerableProperty,
|
|
987
|
-
nop,
|
|
988
1429
|
isDisturbed,
|
|
989
|
-
isErrored,
|
|
990
|
-
isReadable,
|
|
991
|
-
toUSVString,
|
|
992
|
-
isReadableAborted,
|
|
993
1430
|
isBlobLike,
|
|
994
1431
|
parseOrigin,
|
|
995
1432
|
parseURL,
|
|
@@ -999,7 +1436,12 @@ var require_util = __commonJS({
|
|
|
999
1436
|
isAsyncIterable,
|
|
1000
1437
|
isDestroyed,
|
|
1001
1438
|
headerNameToString,
|
|
1439
|
+
bufferToLowerCasedHeaderName,
|
|
1440
|
+
addListener,
|
|
1441
|
+
removeAllListeners,
|
|
1442
|
+
errorRequest,
|
|
1002
1443
|
parseRawHeaders,
|
|
1444
|
+
encodeRawHeaders,
|
|
1003
1445
|
parseHeaders,
|
|
1004
1446
|
parseKeepAliveTimeout,
|
|
1005
1447
|
destroy,
|
|
@@ -1007,309 +1449,359 @@ var require_util = __commonJS({
|
|
|
1007
1449
|
deepClone,
|
|
1008
1450
|
ReadableStreamFrom,
|
|
1009
1451
|
isBuffer,
|
|
1010
|
-
|
|
1452
|
+
assertRequestHandler,
|
|
1011
1453
|
getSocketInfo,
|
|
1012
1454
|
isFormDataLike,
|
|
1013
|
-
|
|
1014
|
-
throwIfAborted,
|
|
1455
|
+
serializePathWithQuery,
|
|
1015
1456
|
addAbortListener,
|
|
1457
|
+
isValidHTTPToken,
|
|
1458
|
+
isValidHeaderValue,
|
|
1459
|
+
isTokenCharCode,
|
|
1016
1460
|
parseRangeHeader,
|
|
1461
|
+
normalizedMethodRecordsBase,
|
|
1462
|
+
normalizedMethodRecords,
|
|
1463
|
+
isValidPort,
|
|
1464
|
+
isHttpOrHttpsPrefixed,
|
|
1017
1465
|
nodeMajor,
|
|
1018
1466
|
nodeMinor,
|
|
1019
|
-
|
|
1020
|
-
|
|
1467
|
+
safeHTTPMethods: Object.freeze(["GET", "HEAD", "OPTIONS", "TRACE"]),
|
|
1468
|
+
wrapRequestBody,
|
|
1469
|
+
setupConnectTimeout
|
|
1021
1470
|
};
|
|
1022
1471
|
}
|
|
1023
1472
|
});
|
|
1024
1473
|
|
|
1025
|
-
// ../../node_modules/.pnpm/undici@
|
|
1026
|
-
var
|
|
1027
|
-
"../../node_modules/.pnpm/undici@
|
|
1474
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/handler/unwrap-handler.js
|
|
1475
|
+
var require_unwrap_handler = __commonJS({
|
|
1476
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/handler/unwrap-handler.js"(exports2, module2) {
|
|
1028
1477
|
"use strict";
|
|
1029
|
-
var
|
|
1030
|
-
var { kBodyUsed } = require_symbols();
|
|
1031
|
-
var assert = require("assert");
|
|
1478
|
+
var { parseHeaders } = require_util();
|
|
1032
1479
|
var { InvalidArgumentError } = require_errors();
|
|
1033
|
-
var
|
|
1034
|
-
var
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1480
|
+
var kResume = Symbol("resume");
|
|
1481
|
+
var UnwrapController = class {
|
|
1482
|
+
#paused = false;
|
|
1483
|
+
#reason = null;
|
|
1484
|
+
#aborted = false;
|
|
1485
|
+
#abort;
|
|
1486
|
+
[kResume] = null;
|
|
1487
|
+
constructor(abort) {
|
|
1488
|
+
this.#abort = abort;
|
|
1040
1489
|
}
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1490
|
+
pause() {
|
|
1491
|
+
this.#paused = true;
|
|
1492
|
+
}
|
|
1493
|
+
resume() {
|
|
1494
|
+
if (this.#paused) {
|
|
1495
|
+
this.#paused = false;
|
|
1496
|
+
this[kResume]?.();
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
abort(reason) {
|
|
1500
|
+
if (!this.#aborted) {
|
|
1501
|
+
this.#aborted = true;
|
|
1502
|
+
this.#reason = reason;
|
|
1503
|
+
this.#abort(reason);
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
get aborted() {
|
|
1507
|
+
return this.#aborted;
|
|
1508
|
+
}
|
|
1509
|
+
get reason() {
|
|
1510
|
+
return this.#reason;
|
|
1511
|
+
}
|
|
1512
|
+
get paused() {
|
|
1513
|
+
return this.#paused;
|
|
1045
1514
|
}
|
|
1046
1515
|
};
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
this
|
|
1058
|
-
this.
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1516
|
+
module2.exports = class UnwrapHandler {
|
|
1517
|
+
#handler;
|
|
1518
|
+
#controller;
|
|
1519
|
+
constructor(handler) {
|
|
1520
|
+
this.#handler = handler;
|
|
1521
|
+
}
|
|
1522
|
+
static unwrap(handler) {
|
|
1523
|
+
return !handler.onRequestStart ? handler : new UnwrapHandler(handler);
|
|
1524
|
+
}
|
|
1525
|
+
onConnect(abort, context) {
|
|
1526
|
+
this.#controller = new UnwrapController(abort);
|
|
1527
|
+
this.#handler.onRequestStart?.(this.#controller, context);
|
|
1528
|
+
}
|
|
1529
|
+
onUpgrade(statusCode, rawHeaders, socket) {
|
|
1530
|
+
this.#handler.onRequestUpgrade?.(this.#controller, statusCode, parseHeaders(rawHeaders), socket);
|
|
1531
|
+
}
|
|
1532
|
+
onHeaders(statusCode, rawHeaders, resume, statusMessage) {
|
|
1533
|
+
this.#controller[kResume] = resume;
|
|
1534
|
+
this.#handler.onResponseStart?.(this.#controller, statusCode, parseHeaders(rawHeaders), statusMessage);
|
|
1535
|
+
return !this.#controller.paused;
|
|
1536
|
+
}
|
|
1537
|
+
onData(data) {
|
|
1538
|
+
this.#handler.onResponseData?.(this.#controller, data);
|
|
1539
|
+
return !this.#controller.paused;
|
|
1540
|
+
}
|
|
1541
|
+
onComplete(rawTrailers) {
|
|
1542
|
+
this.#handler.onResponseEnd?.(this.#controller, parseHeaders(rawTrailers));
|
|
1543
|
+
}
|
|
1544
|
+
onError(err) {
|
|
1545
|
+
if (!this.#handler.onResponseError) {
|
|
1546
|
+
throw new InvalidArgumentError("invalid onError method");
|
|
1076
1547
|
}
|
|
1548
|
+
this.#handler.onResponseError?.(this.#controller, err);
|
|
1077
1549
|
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
});
|
|
1553
|
+
|
|
1554
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/dispatcher/dispatcher-base.js
|
|
1555
|
+
var require_dispatcher_base = __commonJS({
|
|
1556
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/dispatcher/dispatcher-base.js"(exports2, module2) {
|
|
1557
|
+
"use strict";
|
|
1558
|
+
var Dispatcher = require_dispatcher();
|
|
1559
|
+
var UnwrapHandler = require_unwrap_handler();
|
|
1560
|
+
var {
|
|
1561
|
+
ClientDestroyedError,
|
|
1562
|
+
ClientClosedError,
|
|
1563
|
+
InvalidArgumentError
|
|
1564
|
+
} = require_errors();
|
|
1565
|
+
var { kDestroy, kClose, kClosed, kDestroyed, kDispatch } = require_symbols();
|
|
1566
|
+
var kOnDestroyed = Symbol("onDestroyed");
|
|
1567
|
+
var kOnClosed = Symbol("onClosed");
|
|
1568
|
+
var DispatcherBase = class extends Dispatcher {
|
|
1569
|
+
constructor() {
|
|
1570
|
+
super();
|
|
1571
|
+
this[kDestroyed] = false;
|
|
1572
|
+
this[kOnDestroyed] = null;
|
|
1573
|
+
this[kClosed] = false;
|
|
1574
|
+
this[kOnClosed] = [];
|
|
1081
1575
|
}
|
|
1082
|
-
|
|
1083
|
-
this
|
|
1576
|
+
get destroyed() {
|
|
1577
|
+
return this[kDestroyed];
|
|
1084
1578
|
}
|
|
1085
|
-
|
|
1086
|
-
this
|
|
1579
|
+
get closed() {
|
|
1580
|
+
return this[kClosed];
|
|
1087
1581
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1582
|
+
close(callback) {
|
|
1583
|
+
if (callback === void 0) {
|
|
1584
|
+
return new Promise((resolve, reject) => {
|
|
1585
|
+
this.close((err, data) => {
|
|
1586
|
+
return err ? reject(err) : resolve(data);
|
|
1587
|
+
});
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
if (typeof callback !== "function") {
|
|
1591
|
+
throw new InvalidArgumentError("invalid callback");
|
|
1592
|
+
}
|
|
1593
|
+
if (this[kDestroyed]) {
|
|
1594
|
+
queueMicrotask(() => callback(new ClientDestroyedError(), null));
|
|
1595
|
+
return;
|
|
1092
1596
|
}
|
|
1093
|
-
if (
|
|
1094
|
-
|
|
1597
|
+
if (this[kClosed]) {
|
|
1598
|
+
if (this[kOnClosed]) {
|
|
1599
|
+
this[kOnClosed].push(callback);
|
|
1600
|
+
} else {
|
|
1601
|
+
queueMicrotask(() => callback(null, null));
|
|
1602
|
+
}
|
|
1603
|
+
return;
|
|
1095
1604
|
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1605
|
+
this[kClosed] = true;
|
|
1606
|
+
this[kOnClosed].push(callback);
|
|
1607
|
+
const onClosed = () => {
|
|
1608
|
+
const callbacks = this[kOnClosed];
|
|
1609
|
+
this[kOnClosed] = null;
|
|
1610
|
+
for (let i = 0; i < callbacks.length; i++) {
|
|
1611
|
+
callbacks[i](null, null);
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
this[kClose]().then(() => this.destroy()).then(() => {
|
|
1615
|
+
queueMicrotask(onClosed);
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
destroy(err, callback) {
|
|
1619
|
+
if (typeof err === "function") {
|
|
1620
|
+
callback = err;
|
|
1621
|
+
err = null;
|
|
1622
|
+
}
|
|
1623
|
+
if (callback === void 0) {
|
|
1624
|
+
return new Promise((resolve, reject) => {
|
|
1625
|
+
this.destroy(err, (err2, data) => {
|
|
1626
|
+
return err2 ? (
|
|
1627
|
+
/* istanbul ignore next: should never error */
|
|
1628
|
+
reject(err2)
|
|
1629
|
+
) : resolve(data);
|
|
1630
|
+
});
|
|
1631
|
+
});
|
|
1106
1632
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
if (this.location) {
|
|
1110
|
-
} else {
|
|
1111
|
-
return this.handler.onData(chunk);
|
|
1633
|
+
if (typeof callback !== "function") {
|
|
1634
|
+
throw new InvalidArgumentError("invalid callback");
|
|
1112
1635
|
}
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
this.handler.onComplete(trailers);
|
|
1636
|
+
if (this[kDestroyed]) {
|
|
1637
|
+
if (this[kOnDestroyed]) {
|
|
1638
|
+
this[kOnDestroyed].push(callback);
|
|
1639
|
+
} else {
|
|
1640
|
+
queueMicrotask(() => callback(null, null));
|
|
1641
|
+
}
|
|
1642
|
+
return;
|
|
1121
1643
|
}
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
if (this.handler.onBodySent) {
|
|
1125
|
-
this.handler.onBodySent(chunk);
|
|
1644
|
+
if (!err) {
|
|
1645
|
+
err = new ClientDestroyedError();
|
|
1126
1646
|
}
|
|
1647
|
+
this[kDestroyed] = true;
|
|
1648
|
+
this[kOnDestroyed] = this[kOnDestroyed] || [];
|
|
1649
|
+
this[kOnDestroyed].push(callback);
|
|
1650
|
+
const onDestroyed = () => {
|
|
1651
|
+
const callbacks = this[kOnDestroyed];
|
|
1652
|
+
this[kOnDestroyed] = null;
|
|
1653
|
+
for (let i = 0; i < callbacks.length; i++) {
|
|
1654
|
+
callbacks[i](null, null);
|
|
1655
|
+
}
|
|
1656
|
+
};
|
|
1657
|
+
this[kDestroy](err).then(() => {
|
|
1658
|
+
queueMicrotask(onDestroyed);
|
|
1659
|
+
});
|
|
1127
1660
|
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
return null;
|
|
1132
|
-
}
|
|
1133
|
-
for (let i = 0; i < headers.length; i += 2) {
|
|
1134
|
-
if (headers[i].toString().toLowerCase() === "location") {
|
|
1135
|
-
return headers[i + 1];
|
|
1661
|
+
dispatch(opts, handler) {
|
|
1662
|
+
if (!handler || typeof handler !== "object") {
|
|
1663
|
+
throw new InvalidArgumentError("handler must be an object");
|
|
1136
1664
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
return util.headerNameToString(header) === "host";
|
|
1142
|
-
}
|
|
1143
|
-
if (removeContent && util.headerNameToString(header).startsWith("content-")) {
|
|
1144
|
-
return true;
|
|
1145
|
-
}
|
|
1146
|
-
if (unknownOrigin && (header.length === 13 || header.length === 6 || header.length === 19)) {
|
|
1147
|
-
const name = util.headerNameToString(header);
|
|
1148
|
-
return name === "authorization" || name === "cookie" || name === "proxy-authorization";
|
|
1149
|
-
}
|
|
1150
|
-
return false;
|
|
1151
|
-
}
|
|
1152
|
-
function cleanRequestHeaders(headers, removeContent, unknownOrigin) {
|
|
1153
|
-
const ret = [];
|
|
1154
|
-
if (Array.isArray(headers)) {
|
|
1155
|
-
for (let i = 0; i < headers.length; i += 2) {
|
|
1156
|
-
if (!shouldRemoveHeader(headers[i], removeContent, unknownOrigin)) {
|
|
1157
|
-
ret.push(headers[i], headers[i + 1]);
|
|
1665
|
+
handler = UnwrapHandler.unwrap(handler);
|
|
1666
|
+
try {
|
|
1667
|
+
if (!opts || typeof opts !== "object") {
|
|
1668
|
+
throw new InvalidArgumentError("opts must be an object.");
|
|
1158
1669
|
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
if (
|
|
1163
|
-
|
|
1670
|
+
if (this[kDestroyed] || this[kOnDestroyed]) {
|
|
1671
|
+
throw new ClientDestroyedError();
|
|
1672
|
+
}
|
|
1673
|
+
if (this[kClosed]) {
|
|
1674
|
+
throw new ClientClosedError();
|
|
1675
|
+
}
|
|
1676
|
+
return this[kDispatch](opts, handler);
|
|
1677
|
+
} catch (err) {
|
|
1678
|
+
if (typeof handler.onError !== "function") {
|
|
1679
|
+
throw err;
|
|
1164
1680
|
}
|
|
1681
|
+
handler.onError(err);
|
|
1682
|
+
return false;
|
|
1165
1683
|
}
|
|
1166
|
-
} else {
|
|
1167
|
-
assert(headers == null, "headers must be an object or an array");
|
|
1168
1684
|
}
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
module2.exports = RedirectHandler;
|
|
1685
|
+
};
|
|
1686
|
+
module2.exports = DispatcherBase;
|
|
1172
1687
|
}
|
|
1173
1688
|
});
|
|
1174
1689
|
|
|
1175
|
-
//
|
|
1176
|
-
var
|
|
1177
|
-
"
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
if (!maxRedirections) {
|
|
1185
|
-
return dispatch(opts, handler);
|
|
1186
|
-
}
|
|
1187
|
-
const redirectHandler = new RedirectHandler(dispatch, maxRedirections, opts, handler);
|
|
1188
|
-
opts = { ...opts, maxRedirections: 0 };
|
|
1189
|
-
return dispatch(opts, redirectHandler);
|
|
1190
|
-
};
|
|
1191
|
-
};
|
|
1192
|
-
}
|
|
1193
|
-
module2.exports = createRedirectInterceptor;
|
|
1690
|
+
// src/mock-agent/pool.cjs
|
|
1691
|
+
var require_pool = __commonJS({
|
|
1692
|
+
"src/mock-agent/pool.cjs"(exports2, module2) {
|
|
1693
|
+
var assert = require("node:assert");
|
|
1694
|
+
module2.exports = class Pool {
|
|
1695
|
+
constructor() {
|
|
1696
|
+
assert.fail("Pool is not implemented in worker");
|
|
1697
|
+
}
|
|
1698
|
+
};
|
|
1194
1699
|
}
|
|
1195
1700
|
});
|
|
1196
1701
|
|
|
1197
|
-
//
|
|
1198
|
-
var
|
|
1199
|
-
"
|
|
1702
|
+
// src/mock-agent/dispatcher.cjs
|
|
1703
|
+
var require_dispatcher2 = __commonJS({
|
|
1704
|
+
"src/mock-agent/dispatcher.cjs"(exports2, module2) {
|
|
1200
1705
|
"use strict";
|
|
1201
|
-
var
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
|
|
1706
|
+
var dispatcher;
|
|
1707
|
+
module2.exports = {
|
|
1708
|
+
getDispatcher() {
|
|
1709
|
+
return dispatcher;
|
|
1710
|
+
},
|
|
1711
|
+
setDispatcher(newDispatcher) {
|
|
1712
|
+
dispatcher = newDispatcher;
|
|
1208
1713
|
}
|
|
1209
1714
|
};
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1715
|
+
}
|
|
1716
|
+
});
|
|
1717
|
+
|
|
1718
|
+
// src/mock-agent/client.cjs
|
|
1719
|
+
var require_client = __commonJS({
|
|
1720
|
+
"src/mock-agent/client.cjs"(exports2, module2) {
|
|
1721
|
+
var assert = require("node:assert");
|
|
1722
|
+
var DispatcherBase = require_dispatcher_base();
|
|
1723
|
+
var { kDispatch, kClose, kDestroy } = require_symbols();
|
|
1724
|
+
var { getDispatcher } = require_dispatcher2();
|
|
1725
|
+
module2.exports = class Client extends DispatcherBase {
|
|
1726
|
+
[kDispatch](opts, handler) {
|
|
1727
|
+
const dispatcher = getDispatcher();
|
|
1728
|
+
if (dispatcher === void 0) {
|
|
1729
|
+
assert.fail("setDispatcher() must be called before Client#[kDispatch]()");
|
|
1221
1730
|
}
|
|
1731
|
+
dispatcher(opts, handler);
|
|
1732
|
+
return true;
|
|
1222
1733
|
}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
return {
|
|
1227
|
-
WeakRef: CompatWeakRef,
|
|
1228
|
-
FinalizationRegistry: CompatFinalizer
|
|
1229
|
-
};
|
|
1734
|
+
async [kClose]() {
|
|
1735
|
+
}
|
|
1736
|
+
async [kDestroy](_err) {
|
|
1230
1737
|
}
|
|
1231
|
-
return {
|
|
1232
|
-
WeakRef: global.WeakRef || CompatWeakRef,
|
|
1233
|
-
FinalizationRegistry: global.FinalizationRegistry || CompatFinalizer
|
|
1234
|
-
};
|
|
1235
1738
|
};
|
|
1236
1739
|
}
|
|
1237
1740
|
});
|
|
1238
1741
|
|
|
1239
|
-
// ../../node_modules/.pnpm/undici@
|
|
1742
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/dispatcher/agent.js
|
|
1240
1743
|
var require_agent = __commonJS({
|
|
1241
|
-
"../../node_modules/.pnpm/undici@
|
|
1744
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/dispatcher/agent.js"(exports2, module2) {
|
|
1242
1745
|
"use strict";
|
|
1243
1746
|
var { InvalidArgumentError } = require_errors();
|
|
1244
|
-
var { kClients: kClients2, kRunning, kClose, kDestroy, kDispatch,
|
|
1747
|
+
var { kClients: kClients2, kRunning, kClose, kDestroy, kDispatch, kUrl } = require_symbols();
|
|
1245
1748
|
var DispatcherBase = require_dispatcher_base();
|
|
1246
1749
|
var Pool = require_pool();
|
|
1247
1750
|
var Client = require_client();
|
|
1248
1751
|
var util = require_util();
|
|
1249
|
-
var createRedirectInterceptor = require_redirectInterceptor();
|
|
1250
|
-
var { WeakRef, FinalizationRegistry } = require_dispatcher_weakref()();
|
|
1251
1752
|
var kOnConnect = Symbol("onConnect");
|
|
1252
1753
|
var kOnDisconnect = Symbol("onDisconnect");
|
|
1253
1754
|
var kOnConnectionError = Symbol("onConnectionError");
|
|
1254
|
-
var kMaxRedirections = Symbol("maxRedirections");
|
|
1255
1755
|
var kOnDrain = Symbol("onDrain");
|
|
1256
1756
|
var kFactory = Symbol("factory");
|
|
1257
|
-
var kFinalizer = Symbol("finalizer");
|
|
1258
1757
|
var kOptions = Symbol("options");
|
|
1259
1758
|
function defaultFactory(origin, opts) {
|
|
1260
1759
|
return opts && opts.connections === 1 ? new Client(origin, opts) : new Pool(origin, opts);
|
|
1261
1760
|
}
|
|
1262
1761
|
var Agent = class extends DispatcherBase {
|
|
1263
|
-
constructor({ factory = defaultFactory,
|
|
1264
|
-
super();
|
|
1762
|
+
constructor({ factory = defaultFactory, connect, ...options } = {}) {
|
|
1265
1763
|
if (typeof factory !== "function") {
|
|
1266
1764
|
throw new InvalidArgumentError("factory must be a function.");
|
|
1267
1765
|
}
|
|
1268
1766
|
if (connect != null && typeof connect !== "function" && typeof connect !== "object") {
|
|
1269
1767
|
throw new InvalidArgumentError("connect must be a function or an object");
|
|
1270
1768
|
}
|
|
1271
|
-
|
|
1272
|
-
throw new InvalidArgumentError("maxRedirections must be a positive number");
|
|
1273
|
-
}
|
|
1769
|
+
super();
|
|
1274
1770
|
if (connect && typeof connect !== "function") {
|
|
1275
1771
|
connect = { ...connect };
|
|
1276
1772
|
}
|
|
1277
|
-
this[kInterceptors] = options.interceptors && options.interceptors.Agent && Array.isArray(options.interceptors.Agent) ? options.interceptors.Agent : [createRedirectInterceptor({ maxRedirections })];
|
|
1278
1773
|
this[kOptions] = { ...util.deepClone(options), connect };
|
|
1279
|
-
this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0;
|
|
1280
|
-
this[kMaxRedirections] = maxRedirections;
|
|
1281
1774
|
this[kFactory] = factory;
|
|
1282
1775
|
this[kClients2] = /* @__PURE__ */ new Map();
|
|
1283
|
-
this[kFinalizer] = new FinalizationRegistry(
|
|
1284
|
-
/* istanbul ignore next: gc is undeterministic */
|
|
1285
|
-
(key) => {
|
|
1286
|
-
const ref = this[kClients2].get(key);
|
|
1287
|
-
if (ref !== void 0 && ref.deref() === void 0) {
|
|
1288
|
-
this[kClients2].delete(key);
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
);
|
|
1292
|
-
const agent = this;
|
|
1293
1776
|
this[kOnDrain] = (origin, targets) => {
|
|
1294
|
-
|
|
1777
|
+
this.emit("drain", origin, [this, ...targets]);
|
|
1295
1778
|
};
|
|
1296
1779
|
this[kOnConnect] = (origin, targets) => {
|
|
1297
|
-
|
|
1780
|
+
const result = this[kClients2].get(origin);
|
|
1781
|
+
if (result) {
|
|
1782
|
+
result.count += 1;
|
|
1783
|
+
}
|
|
1784
|
+
this.emit("connect", origin, [this, ...targets]);
|
|
1298
1785
|
};
|
|
1299
1786
|
this[kOnDisconnect] = (origin, targets, err) => {
|
|
1300
|
-
|
|
1787
|
+
const result = this[kClients2].get(origin);
|
|
1788
|
+
if (result) {
|
|
1789
|
+
result.count -= 1;
|
|
1790
|
+
if (result.count <= 0) {
|
|
1791
|
+
this[kClients2].delete(origin);
|
|
1792
|
+
result.dispatcher.destroy();
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
this.emit("disconnect", origin, [this, ...targets], err);
|
|
1301
1796
|
};
|
|
1302
1797
|
this[kOnConnectionError] = (origin, targets, err) => {
|
|
1303
|
-
|
|
1798
|
+
this.emit("connectionError", origin, [this, ...targets], err);
|
|
1304
1799
|
};
|
|
1305
1800
|
}
|
|
1306
1801
|
get [kRunning]() {
|
|
1307
1802
|
let ret = 0;
|
|
1308
|
-
for (const
|
|
1309
|
-
|
|
1310
|
-
if (client) {
|
|
1311
|
-
ret += client[kRunning];
|
|
1312
|
-
}
|
|
1803
|
+
for (const { dispatcher } of this[kClients2].values()) {
|
|
1804
|
+
ret += dispatcher[kRunning];
|
|
1313
1805
|
}
|
|
1314
1806
|
return ret;
|
|
1315
1807
|
}
|
|
@@ -1320,43 +1812,47 @@ var require_agent = __commonJS({
|
|
|
1320
1812
|
} else {
|
|
1321
1813
|
throw new InvalidArgumentError("opts.origin must be a non-empty string or URL.");
|
|
1322
1814
|
}
|
|
1323
|
-
const
|
|
1324
|
-
let dispatcher =
|
|
1815
|
+
const result = this[kClients2].get(key);
|
|
1816
|
+
let dispatcher = result && result.dispatcher;
|
|
1325
1817
|
if (!dispatcher) {
|
|
1326
1818
|
dispatcher = this[kFactory](opts.origin, this[kOptions]).on("drain", this[kOnDrain]).on("connect", this[kOnConnect]).on("disconnect", this[kOnDisconnect]).on("connectionError", this[kOnConnectionError]);
|
|
1327
|
-
this[kClients2].set(key,
|
|
1328
|
-
this[kFinalizer].register(dispatcher, key);
|
|
1819
|
+
this[kClients2].set(key, { count: 0, dispatcher });
|
|
1329
1820
|
}
|
|
1330
1821
|
return dispatcher.dispatch(opts, handler);
|
|
1331
1822
|
}
|
|
1332
1823
|
async [kClose]() {
|
|
1333
1824
|
const closePromises = [];
|
|
1334
|
-
for (const
|
|
1335
|
-
|
|
1336
|
-
if (client) {
|
|
1337
|
-
closePromises.push(client.close());
|
|
1338
|
-
}
|
|
1825
|
+
for (const { dispatcher } of this[kClients2].values()) {
|
|
1826
|
+
closePromises.push(dispatcher.close());
|
|
1339
1827
|
}
|
|
1828
|
+
this[kClients2].clear();
|
|
1340
1829
|
await Promise.all(closePromises);
|
|
1341
1830
|
}
|
|
1342
1831
|
async [kDestroy](err) {
|
|
1343
1832
|
const destroyPromises = [];
|
|
1344
|
-
for (const
|
|
1345
|
-
|
|
1346
|
-
if (client) {
|
|
1347
|
-
destroyPromises.push(client.destroy(err));
|
|
1348
|
-
}
|
|
1833
|
+
for (const { dispatcher } of this[kClients2].values()) {
|
|
1834
|
+
destroyPromises.push(dispatcher.destroy(err));
|
|
1349
1835
|
}
|
|
1836
|
+
this[kClients2].clear();
|
|
1350
1837
|
await Promise.all(destroyPromises);
|
|
1351
1838
|
}
|
|
1839
|
+
get stats() {
|
|
1840
|
+
const allClientStats = {};
|
|
1841
|
+
for (const { dispatcher } of this[kClients2].values()) {
|
|
1842
|
+
if (dispatcher.stats) {
|
|
1843
|
+
allClientStats[dispatcher[kUrl].origin] = dispatcher.stats;
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
return allClientStats;
|
|
1847
|
+
}
|
|
1352
1848
|
};
|
|
1353
1849
|
module2.exports = Agent;
|
|
1354
1850
|
}
|
|
1355
1851
|
});
|
|
1356
1852
|
|
|
1357
|
-
// ../../node_modules/.pnpm/undici@
|
|
1853
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-symbols.js
|
|
1358
1854
|
var require_mock_symbols = __commonJS({
|
|
1359
|
-
"../../node_modules/.pnpm/undici@
|
|
1855
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-symbols.js"(exports2, module2) {
|
|
1360
1856
|
"use strict";
|
|
1361
1857
|
module2.exports = {
|
|
1362
1858
|
kAgent: Symbol("agent"),
|
|
@@ -1373,24 +1869,31 @@ var require_mock_symbols = __commonJS({
|
|
|
1373
1869
|
kMockDispatch: Symbol("mock dispatch"),
|
|
1374
1870
|
kClose: Symbol("close"),
|
|
1375
1871
|
kOriginalClose: Symbol("original agent close"),
|
|
1872
|
+
kOriginalDispatch: Symbol("original dispatch"),
|
|
1376
1873
|
kOrigin: Symbol("origin"),
|
|
1377
1874
|
kIsMockActive: Symbol("is mock active"),
|
|
1378
1875
|
kNetConnect: Symbol("net connect"),
|
|
1379
1876
|
kGetNetConnect: Symbol("get net connect"),
|
|
1380
|
-
kConnected: Symbol("connected")
|
|
1877
|
+
kConnected: Symbol("connected"),
|
|
1878
|
+
kIgnoreTrailingSlash: Symbol("ignore trailing slash"),
|
|
1879
|
+
kMockAgentMockCallHistoryInstance: Symbol("mock agent mock call history name"),
|
|
1880
|
+
kMockAgentRegisterCallHistory: Symbol("mock agent register mock call history"),
|
|
1881
|
+
kMockAgentAddCallHistoryLog: Symbol("mock agent add call history log"),
|
|
1882
|
+
kMockAgentIsCallHistoryEnabled: Symbol("mock agent is call history enabled"),
|
|
1883
|
+
kMockAgentAcceptsNonStandardSearchParameters: Symbol("mock agent accepts non standard search parameters"),
|
|
1884
|
+
kMockCallHistoryAddLog: Symbol("mock call history add log")
|
|
1381
1885
|
};
|
|
1382
1886
|
}
|
|
1383
1887
|
});
|
|
1384
1888
|
|
|
1385
|
-
// ../../node_modules/.pnpm/undici@
|
|
1889
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-errors.js
|
|
1386
1890
|
var require_mock_errors = __commonJS({
|
|
1387
|
-
"../../node_modules/.pnpm/undici@
|
|
1891
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-errors.js"(exports2, module2) {
|
|
1388
1892
|
"use strict";
|
|
1389
1893
|
var { UndiciError } = require_errors();
|
|
1390
|
-
var MockNotMatchedError = class
|
|
1894
|
+
var MockNotMatchedError = class extends UndiciError {
|
|
1391
1895
|
constructor(message) {
|
|
1392
1896
|
super(message);
|
|
1393
|
-
Error.captureStackTrace(this, _MockNotMatchedError);
|
|
1394
1897
|
this.name = "MockNotMatchedError";
|
|
1395
1898
|
this.message = message || "The request does not match any registered mock dispatches";
|
|
1396
1899
|
this.code = "UND_MOCK_ERR_MOCK_NOT_MATCHED";
|
|
@@ -1402,9 +1905,9 @@ var require_mock_errors = __commonJS({
|
|
|
1402
1905
|
}
|
|
1403
1906
|
});
|
|
1404
1907
|
|
|
1405
|
-
// ../../node_modules/.pnpm/undici@
|
|
1908
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-utils.js
|
|
1406
1909
|
var require_mock_utils = __commonJS({
|
|
1407
|
-
"../../node_modules/.pnpm/undici@
|
|
1910
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-utils.js"(exports2, module2) {
|
|
1408
1911
|
"use strict";
|
|
1409
1912
|
var { MockNotMatchedError } = require_mock_errors();
|
|
1410
1913
|
var {
|
|
@@ -1414,13 +1917,14 @@ var require_mock_utils = __commonJS({
|
|
|
1414
1917
|
kOrigin,
|
|
1415
1918
|
kGetNetConnect
|
|
1416
1919
|
} = require_mock_symbols();
|
|
1417
|
-
var {
|
|
1418
|
-
var { STATUS_CODES } = require("http");
|
|
1920
|
+
var { serializePathWithQuery } = require_util();
|
|
1921
|
+
var { STATUS_CODES } = require("node:http");
|
|
1419
1922
|
var {
|
|
1420
1923
|
types: {
|
|
1421
1924
|
isPromise
|
|
1422
1925
|
}
|
|
1423
|
-
} = require("util");
|
|
1926
|
+
} = require("node:util");
|
|
1927
|
+
var { InvalidArgumentError } = require_errors();
|
|
1424
1928
|
function matchValue(match, value) {
|
|
1425
1929
|
if (typeof match === "string") {
|
|
1426
1930
|
return match === value;
|
|
@@ -1483,11 +1987,35 @@ var require_mock_utils = __commonJS({
|
|
|
1483
1987
|
}
|
|
1484
1988
|
return true;
|
|
1485
1989
|
}
|
|
1990
|
+
function normalizeSearchParams(query) {
|
|
1991
|
+
if (typeof query !== "string") {
|
|
1992
|
+
return query;
|
|
1993
|
+
}
|
|
1994
|
+
const originalQp = new URLSearchParams(query);
|
|
1995
|
+
const normalizedQp = new URLSearchParams();
|
|
1996
|
+
for (let [key, value] of originalQp.entries()) {
|
|
1997
|
+
key = key.replace("[]", "");
|
|
1998
|
+
const valueRepresentsString = /^(['"]).*\1$/.test(value);
|
|
1999
|
+
if (valueRepresentsString) {
|
|
2000
|
+
normalizedQp.append(key, value);
|
|
2001
|
+
continue;
|
|
2002
|
+
}
|
|
2003
|
+
if (value.includes(",")) {
|
|
2004
|
+
const values = value.split(",");
|
|
2005
|
+
for (const v of values) {
|
|
2006
|
+
normalizedQp.append(key, v);
|
|
2007
|
+
}
|
|
2008
|
+
continue;
|
|
2009
|
+
}
|
|
2010
|
+
normalizedQp.append(key, value);
|
|
2011
|
+
}
|
|
2012
|
+
return normalizedQp;
|
|
2013
|
+
}
|
|
1486
2014
|
function safeUrl(path) {
|
|
1487
2015
|
if (typeof path !== "string") {
|
|
1488
2016
|
return path;
|
|
1489
2017
|
}
|
|
1490
|
-
const pathSegments = path.split("?");
|
|
2018
|
+
const pathSegments = path.split("?", 3);
|
|
1491
2019
|
if (pathSegments.length !== 2) {
|
|
1492
2020
|
return path;
|
|
1493
2021
|
}
|
|
@@ -1505,35 +2033,45 @@ var require_mock_utils = __commonJS({
|
|
|
1505
2033
|
function getResponseData(data) {
|
|
1506
2034
|
if (Buffer.isBuffer(data)) {
|
|
1507
2035
|
return data;
|
|
2036
|
+
} else if (data instanceof Uint8Array) {
|
|
2037
|
+
return data;
|
|
2038
|
+
} else if (data instanceof ArrayBuffer) {
|
|
2039
|
+
return data;
|
|
1508
2040
|
} else if (typeof data === "object") {
|
|
1509
2041
|
return JSON.stringify(data);
|
|
1510
|
-
} else {
|
|
2042
|
+
} else if (data) {
|
|
1511
2043
|
return data.toString();
|
|
2044
|
+
} else {
|
|
2045
|
+
return "";
|
|
1512
2046
|
}
|
|
1513
2047
|
}
|
|
1514
2048
|
function getMockDispatch(mockDispatches, key) {
|
|
1515
|
-
const basePath = key.query ?
|
|
2049
|
+
const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
|
|
1516
2050
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
1517
|
-
|
|
2051
|
+
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
2052
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path, ignoreTrailingSlash }) => {
|
|
2053
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path), resolvedPath);
|
|
2054
|
+
});
|
|
1518
2055
|
if (matchedMockDispatches.length === 0) {
|
|
1519
2056
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
1520
2057
|
}
|
|
1521
2058
|
matchedMockDispatches = matchedMockDispatches.filter(({ method }) => matchValue(method, key.method));
|
|
1522
2059
|
if (matchedMockDispatches.length === 0) {
|
|
1523
|
-
throw new MockNotMatchedError(`Mock dispatch not matched for method '${key.method}'`);
|
|
2060
|
+
throw new MockNotMatchedError(`Mock dispatch not matched for method '${key.method}' on path '${resolvedPath}'`);
|
|
1524
2061
|
}
|
|
1525
2062
|
matchedMockDispatches = matchedMockDispatches.filter(({ body }) => typeof body !== "undefined" ? matchValue(body, key.body) : true);
|
|
1526
2063
|
if (matchedMockDispatches.length === 0) {
|
|
1527
|
-
throw new MockNotMatchedError(`Mock dispatch not matched for body '${key.body}'`);
|
|
2064
|
+
throw new MockNotMatchedError(`Mock dispatch not matched for body '${key.body}' on path '${resolvedPath}'`);
|
|
1528
2065
|
}
|
|
1529
2066
|
matchedMockDispatches = matchedMockDispatches.filter((mockDispatch2) => matchHeaders(mockDispatch2, key.headers));
|
|
1530
2067
|
if (matchedMockDispatches.length === 0) {
|
|
1531
|
-
|
|
2068
|
+
const headers = typeof key.headers === "object" ? JSON.stringify(key.headers) : key.headers;
|
|
2069
|
+
throw new MockNotMatchedError(`Mock dispatch not matched for headers '${headers}' on path '${resolvedPath}'`);
|
|
1532
2070
|
}
|
|
1533
2071
|
return matchedMockDispatches[0];
|
|
1534
2072
|
}
|
|
1535
|
-
function addMockDispatch(mockDispatches, key, data) {
|
|
1536
|
-
const baseData = { timesInvoked: 0, times: 1, persist: false, consumed: false };
|
|
2073
|
+
function addMockDispatch(mockDispatches, key, data, opts) {
|
|
2074
|
+
const baseData = { timesInvoked: 0, times: 1, persist: false, consumed: false, ...opts };
|
|
1537
2075
|
const replyData = typeof data === "function" ? { callback: data } : { ...data };
|
|
1538
2076
|
const newMockDispatch = { ...baseData, ...key, pending: true, data: { error: null, ...replyData } };
|
|
1539
2077
|
mockDispatches.push(newMockDispatch);
|
|
@@ -1550,6 +2088,15 @@ var require_mock_utils = __commonJS({
|
|
|
1550
2088
|
mockDispatches.splice(index, 1);
|
|
1551
2089
|
}
|
|
1552
2090
|
}
|
|
2091
|
+
function removeTrailingSlash(path) {
|
|
2092
|
+
while (path.endsWith("/")) {
|
|
2093
|
+
path = path.slice(0, -1);
|
|
2094
|
+
}
|
|
2095
|
+
if (path.length === 0) {
|
|
2096
|
+
path = "/";
|
|
2097
|
+
}
|
|
2098
|
+
return path;
|
|
2099
|
+
}
|
|
1553
2100
|
function buildKey(opts) {
|
|
1554
2101
|
const { path, method, body, headers, query } = opts;
|
|
1555
2102
|
return {
|
|
@@ -1561,11 +2108,21 @@ var require_mock_utils = __commonJS({
|
|
|
1561
2108
|
};
|
|
1562
2109
|
}
|
|
1563
2110
|
function generateKeyValues(data) {
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
2111
|
+
const keys = Object.keys(data);
|
|
2112
|
+
const result = [];
|
|
2113
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
2114
|
+
const key = keys[i];
|
|
2115
|
+
const value = data[key];
|
|
2116
|
+
const name = Buffer.from(`${key}`);
|
|
2117
|
+
if (Array.isArray(value)) {
|
|
2118
|
+
for (let j = 0; j < value.length; ++j) {
|
|
2119
|
+
result.push(name, Buffer.from(`${value[j]}`));
|
|
2120
|
+
}
|
|
2121
|
+
} else {
|
|
2122
|
+
result.push(name, Buffer.from(`${value}`));
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
return result;
|
|
1569
2126
|
}
|
|
1570
2127
|
function getStatusText(statusCode) {
|
|
1571
2128
|
return STATUS_CODES[statusCode] || "unknown";
|
|
@@ -1610,10 +2167,10 @@ var require_mock_utils = __commonJS({
|
|
|
1610
2167
|
const responseData = getResponseData(body);
|
|
1611
2168
|
const responseHeaders = generateKeyValues(headers);
|
|
1612
2169
|
const responseTrailers = generateKeyValues(trailers);
|
|
1613
|
-
handler.
|
|
1614
|
-
handler.onHeaders(statusCode, responseHeaders, resume, getStatusText(statusCode));
|
|
1615
|
-
handler.onData(Buffer.from(responseData));
|
|
1616
|
-
handler.onComplete(responseTrailers);
|
|
2170
|
+
handler.onConnect?.((err) => handler.onError(err), null);
|
|
2171
|
+
handler.onHeaders?.(statusCode, responseHeaders, resume, getStatusText(statusCode));
|
|
2172
|
+
handler.onData?.(Buffer.from(responseData));
|
|
2173
|
+
handler.onComplete?.(responseTrailers);
|
|
1617
2174
|
deleteMockDispatch(mockDispatches, key);
|
|
1618
2175
|
}
|
|
1619
2176
|
function resume() {
|
|
@@ -1657,9 +2214,15 @@ var require_mock_utils = __commonJS({
|
|
|
1657
2214
|
}
|
|
1658
2215
|
return false;
|
|
1659
2216
|
}
|
|
1660
|
-
function
|
|
2217
|
+
function buildAndValidateMockOptions(opts) {
|
|
1661
2218
|
if (opts) {
|
|
1662
2219
|
const { agent, ...mockOptions } = opts;
|
|
2220
|
+
if ("enableCallHistory" in mockOptions && typeof mockOptions.enableCallHistory !== "boolean") {
|
|
2221
|
+
throw new InvalidArgumentError("options.enableCallHistory must to be a boolean");
|
|
2222
|
+
}
|
|
2223
|
+
if ("acceptNonStandardSearchParameters" in mockOptions && typeof mockOptions.acceptNonStandardSearchParameters !== "boolean") {
|
|
2224
|
+
throw new InvalidArgumentError("options.acceptNonStandardSearchParameters must to be a boolean");
|
|
2225
|
+
}
|
|
1663
2226
|
return mockOptions;
|
|
1664
2227
|
}
|
|
1665
2228
|
}
|
|
@@ -1676,15 +2239,17 @@ var require_mock_utils = __commonJS({
|
|
|
1676
2239
|
mockDispatch,
|
|
1677
2240
|
buildMockDispatch,
|
|
1678
2241
|
checkNetConnect,
|
|
1679
|
-
|
|
1680
|
-
getHeaderByName
|
|
2242
|
+
buildAndValidateMockOptions,
|
|
2243
|
+
getHeaderByName,
|
|
2244
|
+
buildHeadersFromArray,
|
|
2245
|
+
normalizeSearchParams
|
|
1681
2246
|
};
|
|
1682
2247
|
}
|
|
1683
2248
|
});
|
|
1684
2249
|
|
|
1685
|
-
// ../../node_modules/.pnpm/undici@
|
|
2250
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-interceptor.js
|
|
1686
2251
|
var require_mock_interceptor = __commonJS({
|
|
1687
|
-
"../../node_modules/.pnpm/undici@
|
|
2252
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-interceptor.js"(exports2, module2) {
|
|
1688
2253
|
"use strict";
|
|
1689
2254
|
var { getResponseData, buildKey, addMockDispatch } = require_mock_utils();
|
|
1690
2255
|
var {
|
|
@@ -1693,10 +2258,11 @@ var require_mock_interceptor = __commonJS({
|
|
|
1693
2258
|
kDefaultHeaders,
|
|
1694
2259
|
kDefaultTrailers,
|
|
1695
2260
|
kContentLength,
|
|
1696
|
-
kMockDispatch
|
|
2261
|
+
kMockDispatch,
|
|
2262
|
+
kIgnoreTrailingSlash
|
|
1697
2263
|
} = require_mock_symbols();
|
|
1698
2264
|
var { InvalidArgumentError } = require_errors();
|
|
1699
|
-
var {
|
|
2265
|
+
var { serializePathWithQuery } = require_util();
|
|
1700
2266
|
var MockScope = class {
|
|
1701
2267
|
constructor(mockDispatch) {
|
|
1702
2268
|
this[kMockDispatch] = mockDispatch;
|
|
@@ -1742,7 +2308,7 @@ var require_mock_interceptor = __commonJS({
|
|
|
1742
2308
|
}
|
|
1743
2309
|
if (typeof opts.path === "string") {
|
|
1744
2310
|
if (opts.query) {
|
|
1745
|
-
opts.path =
|
|
2311
|
+
opts.path = serializePathWithQuery(opts.path, opts.query);
|
|
1746
2312
|
} else {
|
|
1747
2313
|
const parsedURL = new URL(opts.path, "data://");
|
|
1748
2314
|
opts.path = parsedURL.pathname + parsedURL.search;
|
|
@@ -1753,51 +2319,53 @@ var require_mock_interceptor = __commonJS({
|
|
|
1753
2319
|
}
|
|
1754
2320
|
this[kDispatchKey] = buildKey(opts);
|
|
1755
2321
|
this[kDispatches2] = mockDispatches;
|
|
2322
|
+
this[kIgnoreTrailingSlash] = opts.ignoreTrailingSlash ?? false;
|
|
1756
2323
|
this[kDefaultHeaders] = {};
|
|
1757
2324
|
this[kDefaultTrailers] = {};
|
|
1758
2325
|
this[kContentLength] = false;
|
|
1759
2326
|
}
|
|
1760
|
-
createMockScopeDispatchData(statusCode, data, responseOptions
|
|
2327
|
+
createMockScopeDispatchData({ statusCode, data, responseOptions }) {
|
|
1761
2328
|
const responseData = getResponseData(data);
|
|
1762
2329
|
const contentLength = this[kContentLength] ? { "content-length": responseData.length } : {};
|
|
1763
2330
|
const headers = { ...this[kDefaultHeaders], ...contentLength, ...responseOptions.headers };
|
|
1764
2331
|
const trailers = { ...this[kDefaultTrailers], ...responseOptions.trailers };
|
|
1765
2332
|
return { statusCode, data, headers, trailers };
|
|
1766
2333
|
}
|
|
1767
|
-
validateReplyParameters(
|
|
1768
|
-
if (typeof statusCode === "undefined") {
|
|
2334
|
+
validateReplyParameters(replyParameters) {
|
|
2335
|
+
if (typeof replyParameters.statusCode === "undefined") {
|
|
1769
2336
|
throw new InvalidArgumentError("statusCode must be defined");
|
|
1770
2337
|
}
|
|
1771
|
-
if (typeof
|
|
1772
|
-
throw new InvalidArgumentError("data must be defined");
|
|
1773
|
-
}
|
|
1774
|
-
if (typeof responseOptions !== "object") {
|
|
2338
|
+
if (typeof replyParameters.responseOptions !== "object" || replyParameters.responseOptions === null) {
|
|
1775
2339
|
throw new InvalidArgumentError("responseOptions must be an object");
|
|
1776
2340
|
}
|
|
1777
2341
|
}
|
|
1778
2342
|
/**
|
|
1779
2343
|
* Mock an undici request with a defined reply.
|
|
1780
2344
|
*/
|
|
1781
|
-
reply(
|
|
1782
|
-
if (typeof
|
|
2345
|
+
reply(replyOptionsCallbackOrStatusCode) {
|
|
2346
|
+
if (typeof replyOptionsCallbackOrStatusCode === "function") {
|
|
1783
2347
|
const wrappedDefaultsCallback = (opts) => {
|
|
1784
|
-
const resolvedData =
|
|
1785
|
-
if (typeof resolvedData !== "object") {
|
|
2348
|
+
const resolvedData = replyOptionsCallbackOrStatusCode(opts);
|
|
2349
|
+
if (typeof resolvedData !== "object" || resolvedData === null) {
|
|
1786
2350
|
throw new InvalidArgumentError("reply options callback must return an object");
|
|
1787
2351
|
}
|
|
1788
|
-
const
|
|
1789
|
-
this.validateReplyParameters(
|
|
2352
|
+
const replyParameters2 = { data: "", responseOptions: {}, ...resolvedData };
|
|
2353
|
+
this.validateReplyParameters(replyParameters2);
|
|
1790
2354
|
return {
|
|
1791
|
-
...this.createMockScopeDispatchData(
|
|
2355
|
+
...this.createMockScopeDispatchData(replyParameters2)
|
|
1792
2356
|
};
|
|
1793
2357
|
};
|
|
1794
|
-
const newMockDispatch2 = addMockDispatch(this[kDispatches2], this[kDispatchKey], wrappedDefaultsCallback);
|
|
2358
|
+
const newMockDispatch2 = addMockDispatch(this[kDispatches2], this[kDispatchKey], wrappedDefaultsCallback, { ignoreTrailingSlash: this[kIgnoreTrailingSlash] });
|
|
1795
2359
|
return new MockScope(newMockDispatch2);
|
|
1796
2360
|
}
|
|
1797
|
-
const
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
2361
|
+
const replyParameters = {
|
|
2362
|
+
statusCode: replyOptionsCallbackOrStatusCode,
|
|
2363
|
+
data: arguments[1] === void 0 ? "" : arguments[1],
|
|
2364
|
+
responseOptions: arguments[2] === void 0 ? {} : arguments[2]
|
|
2365
|
+
};
|
|
2366
|
+
this.validateReplyParameters(replyParameters);
|
|
2367
|
+
const dispatchData = this.createMockScopeDispatchData(replyParameters);
|
|
2368
|
+
const newMockDispatch = addMockDispatch(this[kDispatches2], this[kDispatchKey], dispatchData, { ignoreTrailingSlash: this[kIgnoreTrailingSlash] });
|
|
1801
2369
|
return new MockScope(newMockDispatch);
|
|
1802
2370
|
}
|
|
1803
2371
|
/**
|
|
@@ -1807,7 +2375,7 @@ var require_mock_interceptor = __commonJS({
|
|
|
1807
2375
|
if (typeof error === "undefined") {
|
|
1808
2376
|
throw new InvalidArgumentError("error must be defined");
|
|
1809
2377
|
}
|
|
1810
|
-
const newMockDispatch = addMockDispatch(this[kDispatches2], this[kDispatchKey], { error });
|
|
2378
|
+
const newMockDispatch = addMockDispatch(this[kDispatches2], this[kDispatchKey], { error }, { ignoreTrailingSlash: this[kIgnoreTrailingSlash] });
|
|
1811
2379
|
return new MockScope(newMockDispatch);
|
|
1812
2380
|
}
|
|
1813
2381
|
/**
|
|
@@ -1843,11 +2411,11 @@ var require_mock_interceptor = __commonJS({
|
|
|
1843
2411
|
}
|
|
1844
2412
|
});
|
|
1845
2413
|
|
|
1846
|
-
// ../../node_modules/.pnpm/undici@
|
|
2414
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-client.js
|
|
1847
2415
|
var require_mock_client = __commonJS({
|
|
1848
|
-
"../../node_modules/.pnpm/undici@
|
|
2416
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-client.js"(exports2, module2) {
|
|
1849
2417
|
"use strict";
|
|
1850
|
-
var { promisify } = require("util");
|
|
2418
|
+
var { promisify } = require("node:util");
|
|
1851
2419
|
var Client = require_client();
|
|
1852
2420
|
var { buildMockDispatch } = require_mock_utils();
|
|
1853
2421
|
var {
|
|
@@ -1857,19 +2425,21 @@ var require_mock_client = __commonJS({
|
|
|
1857
2425
|
kOriginalClose,
|
|
1858
2426
|
kOrigin,
|
|
1859
2427
|
kOriginalDispatch,
|
|
1860
|
-
kConnected
|
|
2428
|
+
kConnected,
|
|
2429
|
+
kIgnoreTrailingSlash
|
|
1861
2430
|
} = require_mock_symbols();
|
|
1862
2431
|
var { MockInterceptor } = require_mock_interceptor();
|
|
1863
2432
|
var Symbols = require_symbols();
|
|
1864
2433
|
var { InvalidArgumentError } = require_errors();
|
|
1865
2434
|
var MockClient = class extends Client {
|
|
1866
2435
|
constructor(origin, opts) {
|
|
1867
|
-
super(origin, opts);
|
|
1868
2436
|
if (!opts || !opts.agent || typeof opts.agent.dispatch !== "function") {
|
|
1869
2437
|
throw new InvalidArgumentError("Argument opts.agent must implement Agent");
|
|
1870
2438
|
}
|
|
2439
|
+
super(origin, opts);
|
|
1871
2440
|
this[kMockAgent] = opts.agent;
|
|
1872
2441
|
this[kOrigin] = origin;
|
|
2442
|
+
this[kIgnoreTrailingSlash] = opts.ignoreTrailingSlash ?? false;
|
|
1873
2443
|
this[kDispatches2] = [];
|
|
1874
2444
|
this[kConnected] = 1;
|
|
1875
2445
|
this[kOriginalDispatch] = this.dispatch;
|
|
@@ -1884,7 +2454,13 @@ var require_mock_client = __commonJS({
|
|
|
1884
2454
|
* Sets up the base interceptor for mocking replies from undici.
|
|
1885
2455
|
*/
|
|
1886
2456
|
intercept(opts) {
|
|
1887
|
-
return new MockInterceptor(
|
|
2457
|
+
return new MockInterceptor(
|
|
2458
|
+
opts && { ignoreTrailingSlash: this[kIgnoreTrailingSlash], ...opts },
|
|
2459
|
+
this[kDispatches2]
|
|
2460
|
+
);
|
|
2461
|
+
}
|
|
2462
|
+
cleanMocks() {
|
|
2463
|
+
this[kDispatches2] = [];
|
|
1888
2464
|
}
|
|
1889
2465
|
async [kClose]() {
|
|
1890
2466
|
await promisify(this[kOriginalClose])();
|
|
@@ -1896,11 +2472,11 @@ var require_mock_client = __commonJS({
|
|
|
1896
2472
|
}
|
|
1897
2473
|
});
|
|
1898
2474
|
|
|
1899
|
-
// ../../node_modules/.pnpm/undici@
|
|
2475
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-pool.js
|
|
1900
2476
|
var require_mock_pool = __commonJS({
|
|
1901
|
-
"../../node_modules/.pnpm/undici@
|
|
2477
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-pool.js"(exports2, module2) {
|
|
1902
2478
|
"use strict";
|
|
1903
|
-
var { promisify } = require("util");
|
|
2479
|
+
var { promisify } = require("node:util");
|
|
1904
2480
|
var Pool = require_pool();
|
|
1905
2481
|
var { buildMockDispatch } = require_mock_utils();
|
|
1906
2482
|
var {
|
|
@@ -1910,19 +2486,21 @@ var require_mock_pool = __commonJS({
|
|
|
1910
2486
|
kOriginalClose,
|
|
1911
2487
|
kOrigin,
|
|
1912
2488
|
kOriginalDispatch,
|
|
1913
|
-
kConnected
|
|
2489
|
+
kConnected,
|
|
2490
|
+
kIgnoreTrailingSlash
|
|
1914
2491
|
} = require_mock_symbols();
|
|
1915
2492
|
var { MockInterceptor } = require_mock_interceptor();
|
|
1916
2493
|
var Symbols = require_symbols();
|
|
1917
2494
|
var { InvalidArgumentError } = require_errors();
|
|
1918
2495
|
var MockPool = class extends Pool {
|
|
1919
2496
|
constructor(origin, opts) {
|
|
1920
|
-
super(origin, opts);
|
|
1921
2497
|
if (!opts || !opts.agent || typeof opts.agent.dispatch !== "function") {
|
|
1922
2498
|
throw new InvalidArgumentError("Argument opts.agent must implement Agent");
|
|
1923
2499
|
}
|
|
2500
|
+
super(origin, opts);
|
|
1924
2501
|
this[kMockAgent] = opts.agent;
|
|
1925
2502
|
this[kOrigin] = origin;
|
|
2503
|
+
this[kIgnoreTrailingSlash] = opts.ignoreTrailingSlash ?? false;
|
|
1926
2504
|
this[kDispatches2] = [];
|
|
1927
2505
|
this[kConnected] = 1;
|
|
1928
2506
|
this[kOriginalDispatch] = this.dispatch;
|
|
@@ -1937,7 +2515,13 @@ var require_mock_pool = __commonJS({
|
|
|
1937
2515
|
* Sets up the base interceptor for mocking replies from undici.
|
|
1938
2516
|
*/
|
|
1939
2517
|
intercept(opts) {
|
|
1940
|
-
return new MockInterceptor(
|
|
2518
|
+
return new MockInterceptor(
|
|
2519
|
+
opts && { ignoreTrailingSlash: this[kIgnoreTrailingSlash], ...opts },
|
|
2520
|
+
this[kDispatches2]
|
|
2521
|
+
);
|
|
2522
|
+
}
|
|
2523
|
+
cleanMocks() {
|
|
2524
|
+
this[kDispatches2] = [];
|
|
1941
2525
|
}
|
|
1942
2526
|
async [kClose]() {
|
|
1943
2527
|
await promisify(this[kOriginalClose])();
|
|
@@ -1949,37 +2533,6 @@ var require_mock_pool = __commonJS({
|
|
|
1949
2533
|
}
|
|
1950
2534
|
});
|
|
1951
2535
|
|
|
1952
|
-
// ../../node_modules/.pnpm/undici@5.28.5/node_modules/undici/lib/mock/pluralizer.js
|
|
1953
|
-
var require_pluralizer = __commonJS({
|
|
1954
|
-
"../../node_modules/.pnpm/undici@5.28.5/node_modules/undici/lib/mock/pluralizer.js"(exports2, module2) {
|
|
1955
|
-
"use strict";
|
|
1956
|
-
var singulars = {
|
|
1957
|
-
pronoun: "it",
|
|
1958
|
-
is: "is",
|
|
1959
|
-
was: "was",
|
|
1960
|
-
this: "this"
|
|
1961
|
-
};
|
|
1962
|
-
var plurals = {
|
|
1963
|
-
pronoun: "they",
|
|
1964
|
-
is: "are",
|
|
1965
|
-
was: "were",
|
|
1966
|
-
this: "these"
|
|
1967
|
-
};
|
|
1968
|
-
module2.exports = class Pluralizer {
|
|
1969
|
-
constructor(singular, plural) {
|
|
1970
|
-
this.singular = singular;
|
|
1971
|
-
this.plural = plural;
|
|
1972
|
-
}
|
|
1973
|
-
pluralize(count) {
|
|
1974
|
-
const one = count === 1;
|
|
1975
|
-
const keys = one ? singulars : plurals;
|
|
1976
|
-
const noun = one ? this.singular : this.plural;
|
|
1977
|
-
return { ...keys, count, noun };
|
|
1978
|
-
}
|
|
1979
|
-
};
|
|
1980
|
-
}
|
|
1981
|
-
});
|
|
1982
|
-
|
|
1983
2536
|
// src/mock-agent/pending-interceptor-formatter.cjs
|
|
1984
2537
|
var require_pending_interceptor_formatter = __commonJS({
|
|
1985
2538
|
"src/mock-agent/pending-interceptor-formatter.cjs"(exports2, module2) {
|
|
@@ -2017,9 +2570,209 @@ var require_pending_interceptor_formatter = __commonJS({
|
|
|
2017
2570
|
}
|
|
2018
2571
|
});
|
|
2019
2572
|
|
|
2020
|
-
// ../../node_modules/.pnpm/undici@
|
|
2573
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-call-history.js
|
|
2574
|
+
var require_mock_call_history = __commonJS({
|
|
2575
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-call-history.js"(exports2, module2) {
|
|
2576
|
+
"use strict";
|
|
2577
|
+
var { kMockCallHistoryAddLog } = require_mock_symbols();
|
|
2578
|
+
var { InvalidArgumentError } = require_errors();
|
|
2579
|
+
function handleFilterCallsWithOptions(criteria, options, handler, store) {
|
|
2580
|
+
switch (options.operator) {
|
|
2581
|
+
case "OR":
|
|
2582
|
+
store.push(...handler(criteria));
|
|
2583
|
+
return store;
|
|
2584
|
+
case "AND":
|
|
2585
|
+
return handler.call({ logs: store }, criteria);
|
|
2586
|
+
default:
|
|
2587
|
+
throw new InvalidArgumentError("options.operator must to be a case insensitive string equal to 'OR' or 'AND'");
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
function buildAndValidateFilterCallsOptions(options = {}) {
|
|
2591
|
+
const finalOptions = {};
|
|
2592
|
+
if ("operator" in options) {
|
|
2593
|
+
if (typeof options.operator !== "string" || options.operator.toUpperCase() !== "OR" && options.operator.toUpperCase() !== "AND") {
|
|
2594
|
+
throw new InvalidArgumentError("options.operator must to be a case insensitive string equal to 'OR' or 'AND'");
|
|
2595
|
+
}
|
|
2596
|
+
return {
|
|
2597
|
+
...finalOptions,
|
|
2598
|
+
operator: options.operator.toUpperCase()
|
|
2599
|
+
};
|
|
2600
|
+
}
|
|
2601
|
+
return finalOptions;
|
|
2602
|
+
}
|
|
2603
|
+
function makeFilterCalls(parameterName) {
|
|
2604
|
+
return (parameterValue) => {
|
|
2605
|
+
if (typeof parameterValue === "string" || parameterValue == null) {
|
|
2606
|
+
return this.logs.filter((log) => {
|
|
2607
|
+
return log[parameterName] === parameterValue;
|
|
2608
|
+
});
|
|
2609
|
+
}
|
|
2610
|
+
if (parameterValue instanceof RegExp) {
|
|
2611
|
+
return this.logs.filter((log) => {
|
|
2612
|
+
return parameterValue.test(log[parameterName]);
|
|
2613
|
+
});
|
|
2614
|
+
}
|
|
2615
|
+
throw new InvalidArgumentError(`${parameterName} parameter should be one of string, regexp, undefined or null`);
|
|
2616
|
+
};
|
|
2617
|
+
}
|
|
2618
|
+
function computeUrlWithMaybeSearchParameters(requestInit) {
|
|
2619
|
+
try {
|
|
2620
|
+
const url = new URL(requestInit.path, requestInit.origin);
|
|
2621
|
+
if (url.search.length !== 0) {
|
|
2622
|
+
return url;
|
|
2623
|
+
}
|
|
2624
|
+
url.search = new URLSearchParams(requestInit.query).toString();
|
|
2625
|
+
return url;
|
|
2626
|
+
} catch (error) {
|
|
2627
|
+
throw new InvalidArgumentError("An error occurred when computing MockCallHistoryLog.url", { cause: error });
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
var MockCallHistoryLog = class {
|
|
2631
|
+
constructor(requestInit = {}) {
|
|
2632
|
+
this.body = requestInit.body;
|
|
2633
|
+
this.headers = requestInit.headers;
|
|
2634
|
+
this.method = requestInit.method;
|
|
2635
|
+
const url = computeUrlWithMaybeSearchParameters(requestInit);
|
|
2636
|
+
this.fullUrl = url.toString();
|
|
2637
|
+
this.origin = url.origin;
|
|
2638
|
+
this.path = url.pathname;
|
|
2639
|
+
this.searchParams = Object.fromEntries(url.searchParams);
|
|
2640
|
+
this.protocol = url.protocol;
|
|
2641
|
+
this.host = url.host;
|
|
2642
|
+
this.port = url.port;
|
|
2643
|
+
this.hash = url.hash;
|
|
2644
|
+
}
|
|
2645
|
+
toMap() {
|
|
2646
|
+
return /* @__PURE__ */ new Map(
|
|
2647
|
+
[
|
|
2648
|
+
["protocol", this.protocol],
|
|
2649
|
+
["host", this.host],
|
|
2650
|
+
["port", this.port],
|
|
2651
|
+
["origin", this.origin],
|
|
2652
|
+
["path", this.path],
|
|
2653
|
+
["hash", this.hash],
|
|
2654
|
+
["searchParams", this.searchParams],
|
|
2655
|
+
["fullUrl", this.fullUrl],
|
|
2656
|
+
["method", this.method],
|
|
2657
|
+
["body", this.body],
|
|
2658
|
+
["headers", this.headers]
|
|
2659
|
+
]
|
|
2660
|
+
);
|
|
2661
|
+
}
|
|
2662
|
+
toString() {
|
|
2663
|
+
const options = { betweenKeyValueSeparator: "->", betweenPairSeparator: "|" };
|
|
2664
|
+
let result = "";
|
|
2665
|
+
this.toMap().forEach((value, key) => {
|
|
2666
|
+
if (typeof value === "string" || value === void 0 || value === null) {
|
|
2667
|
+
result = `${result}${key}${options.betweenKeyValueSeparator}${value}${options.betweenPairSeparator}`;
|
|
2668
|
+
}
|
|
2669
|
+
if (typeof value === "object" && value !== null || Array.isArray(value)) {
|
|
2670
|
+
result = `${result}${key}${options.betweenKeyValueSeparator}${JSON.stringify(value)}${options.betweenPairSeparator}`;
|
|
2671
|
+
}
|
|
2672
|
+
});
|
|
2673
|
+
return result.slice(0, -1);
|
|
2674
|
+
}
|
|
2675
|
+
};
|
|
2676
|
+
var MockCallHistory = class {
|
|
2677
|
+
logs = [];
|
|
2678
|
+
calls() {
|
|
2679
|
+
return this.logs;
|
|
2680
|
+
}
|
|
2681
|
+
firstCall() {
|
|
2682
|
+
return this.logs.at(0);
|
|
2683
|
+
}
|
|
2684
|
+
lastCall() {
|
|
2685
|
+
return this.logs.at(-1);
|
|
2686
|
+
}
|
|
2687
|
+
nthCall(number) {
|
|
2688
|
+
if (typeof number !== "number") {
|
|
2689
|
+
throw new InvalidArgumentError("nthCall must be called with a number");
|
|
2690
|
+
}
|
|
2691
|
+
if (!Number.isInteger(number)) {
|
|
2692
|
+
throw new InvalidArgumentError("nthCall must be called with an integer");
|
|
2693
|
+
}
|
|
2694
|
+
if (Math.sign(number) !== 1) {
|
|
2695
|
+
throw new InvalidArgumentError("nthCall must be called with a positive value. use firstCall or lastCall instead");
|
|
2696
|
+
}
|
|
2697
|
+
return this.logs.at(number - 1);
|
|
2698
|
+
}
|
|
2699
|
+
filterCalls(criteria, options) {
|
|
2700
|
+
if (this.logs.length === 0) {
|
|
2701
|
+
return this.logs;
|
|
2702
|
+
}
|
|
2703
|
+
if (typeof criteria === "function") {
|
|
2704
|
+
return this.logs.filter(criteria);
|
|
2705
|
+
}
|
|
2706
|
+
if (criteria instanceof RegExp) {
|
|
2707
|
+
return this.logs.filter((log) => {
|
|
2708
|
+
return criteria.test(log.toString());
|
|
2709
|
+
});
|
|
2710
|
+
}
|
|
2711
|
+
if (typeof criteria === "object" && criteria !== null) {
|
|
2712
|
+
if (Object.keys(criteria).length === 0) {
|
|
2713
|
+
return this.logs;
|
|
2714
|
+
}
|
|
2715
|
+
const finalOptions = { operator: "OR", ...buildAndValidateFilterCallsOptions(options) };
|
|
2716
|
+
let maybeDuplicatedLogsFiltered = [];
|
|
2717
|
+
if ("protocol" in criteria) {
|
|
2718
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.protocol, finalOptions, this.filterCallsByProtocol, maybeDuplicatedLogsFiltered);
|
|
2719
|
+
}
|
|
2720
|
+
if ("host" in criteria) {
|
|
2721
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.host, finalOptions, this.filterCallsByHost, maybeDuplicatedLogsFiltered);
|
|
2722
|
+
}
|
|
2723
|
+
if ("port" in criteria) {
|
|
2724
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.port, finalOptions, this.filterCallsByPort, maybeDuplicatedLogsFiltered);
|
|
2725
|
+
}
|
|
2726
|
+
if ("origin" in criteria) {
|
|
2727
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.origin, finalOptions, this.filterCallsByOrigin, maybeDuplicatedLogsFiltered);
|
|
2728
|
+
}
|
|
2729
|
+
if ("path" in criteria) {
|
|
2730
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.path, finalOptions, this.filterCallsByPath, maybeDuplicatedLogsFiltered);
|
|
2731
|
+
}
|
|
2732
|
+
if ("hash" in criteria) {
|
|
2733
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.hash, finalOptions, this.filterCallsByHash, maybeDuplicatedLogsFiltered);
|
|
2734
|
+
}
|
|
2735
|
+
if ("fullUrl" in criteria) {
|
|
2736
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.fullUrl, finalOptions, this.filterCallsByFullUrl, maybeDuplicatedLogsFiltered);
|
|
2737
|
+
}
|
|
2738
|
+
if ("method" in criteria) {
|
|
2739
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.method, finalOptions, this.filterCallsByMethod, maybeDuplicatedLogsFiltered);
|
|
2740
|
+
}
|
|
2741
|
+
const uniqLogsFiltered = [...new Set(maybeDuplicatedLogsFiltered)];
|
|
2742
|
+
return uniqLogsFiltered;
|
|
2743
|
+
}
|
|
2744
|
+
throw new InvalidArgumentError("criteria parameter should be one of function, regexp, or object");
|
|
2745
|
+
}
|
|
2746
|
+
filterCallsByProtocol = makeFilterCalls.call(this, "protocol");
|
|
2747
|
+
filterCallsByHost = makeFilterCalls.call(this, "host");
|
|
2748
|
+
filterCallsByPort = makeFilterCalls.call(this, "port");
|
|
2749
|
+
filterCallsByOrigin = makeFilterCalls.call(this, "origin");
|
|
2750
|
+
filterCallsByPath = makeFilterCalls.call(this, "path");
|
|
2751
|
+
filterCallsByHash = makeFilterCalls.call(this, "hash");
|
|
2752
|
+
filterCallsByFullUrl = makeFilterCalls.call(this, "fullUrl");
|
|
2753
|
+
filterCallsByMethod = makeFilterCalls.call(this, "method");
|
|
2754
|
+
clear() {
|
|
2755
|
+
this.logs = [];
|
|
2756
|
+
}
|
|
2757
|
+
[kMockCallHistoryAddLog](requestInit) {
|
|
2758
|
+
const log = new MockCallHistoryLog(requestInit);
|
|
2759
|
+
this.logs.push(log);
|
|
2760
|
+
return log;
|
|
2761
|
+
}
|
|
2762
|
+
*[Symbol.iterator]() {
|
|
2763
|
+
for (const log of this.calls()) {
|
|
2764
|
+
yield log;
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
};
|
|
2768
|
+
module2.exports.MockCallHistory = MockCallHistory;
|
|
2769
|
+
module2.exports.MockCallHistoryLog = MockCallHistoryLog;
|
|
2770
|
+
}
|
|
2771
|
+
});
|
|
2772
|
+
|
|
2773
|
+
// ../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-agent.js
|
|
2021
2774
|
var require_mock_agent = __commonJS({
|
|
2022
|
-
"../../node_modules/.pnpm/undici@
|
|
2775
|
+
"../../node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-agent.js"(exports2, module2) {
|
|
2023
2776
|
"use strict";
|
|
2024
2777
|
var { kClients: kClients2 } = require_symbols();
|
|
2025
2778
|
var Agent = require_agent();
|
|
@@ -2032,35 +2785,39 @@ var require_mock_agent = __commonJS({
|
|
|
2032
2785
|
kNetConnect,
|
|
2033
2786
|
kGetNetConnect,
|
|
2034
2787
|
kOptions,
|
|
2035
|
-
kFactory
|
|
2788
|
+
kFactory,
|
|
2789
|
+
kMockAgentRegisterCallHistory,
|
|
2790
|
+
kMockAgentIsCallHistoryEnabled,
|
|
2791
|
+
kMockAgentAddCallHistoryLog,
|
|
2792
|
+
kMockAgentMockCallHistoryInstance,
|
|
2793
|
+
kMockAgentAcceptsNonStandardSearchParameters,
|
|
2794
|
+
kMockCallHistoryAddLog
|
|
2036
2795
|
} = require_mock_symbols();
|
|
2037
2796
|
var MockClient = require_mock_client();
|
|
2038
2797
|
var MockPool = require_mock_pool();
|
|
2039
|
-
var { matchValue,
|
|
2798
|
+
var { matchValue, normalizeSearchParams, buildAndValidateMockOptions } = require_mock_utils();
|
|
2040
2799
|
var { InvalidArgumentError, UndiciError } = require_errors();
|
|
2041
2800
|
var Dispatcher = require_dispatcher();
|
|
2042
|
-
var Pluralizer = require_pluralizer();
|
|
2043
2801
|
var PendingInterceptorsFormatter = require_pending_interceptor_formatter();
|
|
2044
|
-
var
|
|
2045
|
-
constructor(value) {
|
|
2046
|
-
this.value = value;
|
|
2047
|
-
}
|
|
2048
|
-
deref() {
|
|
2049
|
-
return this.value;
|
|
2050
|
-
}
|
|
2051
|
-
};
|
|
2802
|
+
var { MockCallHistory } = require_mock_call_history();
|
|
2052
2803
|
var MockAgent2 = class extends Dispatcher {
|
|
2053
2804
|
constructor(opts) {
|
|
2054
2805
|
super(opts);
|
|
2806
|
+
const mockOptions = buildAndValidateMockOptions(opts);
|
|
2055
2807
|
this[kNetConnect] = true;
|
|
2056
2808
|
this[kIsMockActive2] = true;
|
|
2057
|
-
|
|
2809
|
+
this[kMockAgentIsCallHistoryEnabled] = mockOptions?.enableCallHistory ?? false;
|
|
2810
|
+
this[kMockAgentAcceptsNonStandardSearchParameters] = mockOptions?.acceptNonStandardSearchParameters ?? false;
|
|
2811
|
+
if (opts?.agent && typeof opts.agent.dispatch !== "function") {
|
|
2058
2812
|
throw new InvalidArgumentError("Argument opts.agent must implement Agent");
|
|
2059
2813
|
}
|
|
2060
|
-
const agent = opts
|
|
2814
|
+
const agent = opts?.agent ? opts.agent : new Agent(opts);
|
|
2061
2815
|
this[kAgent] = agent;
|
|
2062
2816
|
this[kClients2] = agent[kClients2];
|
|
2063
|
-
this[kOptions] =
|
|
2817
|
+
this[kOptions] = mockOptions;
|
|
2818
|
+
if (this[kMockAgentIsCallHistoryEnabled]) {
|
|
2819
|
+
this[kMockAgentRegisterCallHistory]();
|
|
2820
|
+
}
|
|
2064
2821
|
}
|
|
2065
2822
|
get(origin) {
|
|
2066
2823
|
let dispatcher = this[kMockAgentGet](origin);
|
|
@@ -2072,9 +2829,18 @@ var require_mock_agent = __commonJS({
|
|
|
2072
2829
|
}
|
|
2073
2830
|
dispatch(opts, handler) {
|
|
2074
2831
|
this.get(opts.origin);
|
|
2075
|
-
|
|
2832
|
+
this[kMockAgentAddCallHistoryLog](opts);
|
|
2833
|
+
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
2834
|
+
const dispatchOpts = { ...opts };
|
|
2835
|
+
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
2836
|
+
const [path, searchParams] = dispatchOpts.path.split("?");
|
|
2837
|
+
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
2838
|
+
dispatchOpts.path = `${path}?${normalizedSearchParams}`;
|
|
2839
|
+
}
|
|
2840
|
+
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
2076
2841
|
}
|
|
2077
2842
|
async close() {
|
|
2843
|
+
this.clearCallHistory();
|
|
2078
2844
|
await this[kAgent].close();
|
|
2079
2845
|
this[kClients2].clear();
|
|
2080
2846
|
}
|
|
@@ -2100,34 +2866,60 @@ var require_mock_agent = __commonJS({
|
|
|
2100
2866
|
disableNetConnect() {
|
|
2101
2867
|
this[kNetConnect] = false;
|
|
2102
2868
|
}
|
|
2869
|
+
enableCallHistory() {
|
|
2870
|
+
this[kMockAgentIsCallHistoryEnabled] = true;
|
|
2871
|
+
return this;
|
|
2872
|
+
}
|
|
2873
|
+
disableCallHistory() {
|
|
2874
|
+
this[kMockAgentIsCallHistoryEnabled] = false;
|
|
2875
|
+
return this;
|
|
2876
|
+
}
|
|
2877
|
+
getCallHistory() {
|
|
2878
|
+
return this[kMockAgentMockCallHistoryInstance];
|
|
2879
|
+
}
|
|
2880
|
+
clearCallHistory() {
|
|
2881
|
+
if (this[kMockAgentMockCallHistoryInstance] !== void 0) {
|
|
2882
|
+
this[kMockAgentMockCallHistoryInstance].clear();
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2103
2885
|
// This is required to bypass issues caused by using global symbols - see:
|
|
2104
2886
|
// https://github.com/nodejs/undici/issues/1447
|
|
2105
2887
|
get isMockActive() {
|
|
2106
2888
|
return this[kIsMockActive2];
|
|
2107
2889
|
}
|
|
2890
|
+
[kMockAgentRegisterCallHistory]() {
|
|
2891
|
+
if (this[kMockAgentMockCallHistoryInstance] === void 0) {
|
|
2892
|
+
this[kMockAgentMockCallHistoryInstance] = new MockCallHistory();
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
[kMockAgentAddCallHistoryLog](opts) {
|
|
2896
|
+
if (this[kMockAgentIsCallHistoryEnabled]) {
|
|
2897
|
+
this[kMockAgentRegisterCallHistory]();
|
|
2898
|
+
this[kMockAgentMockCallHistoryInstance][kMockCallHistoryAddLog](opts);
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2108
2901
|
[kMockAgentSet](origin, dispatcher) {
|
|
2109
|
-
this[kClients2].set(origin,
|
|
2902
|
+
this[kClients2].set(origin, { count: 0, dispatcher });
|
|
2110
2903
|
}
|
|
2111
2904
|
[kFactory](origin) {
|
|
2112
2905
|
const mockOptions = Object.assign({ agent: this }, this[kOptions]);
|
|
2113
2906
|
return this[kOptions] && this[kOptions].connections === 1 ? new MockClient(origin, mockOptions) : new MockPool(origin, mockOptions);
|
|
2114
2907
|
}
|
|
2115
2908
|
[kMockAgentGet](origin) {
|
|
2116
|
-
const
|
|
2117
|
-
if (
|
|
2118
|
-
return
|
|
2909
|
+
const result = this[kClients2].get(origin);
|
|
2910
|
+
if (result?.dispatcher) {
|
|
2911
|
+
return result.dispatcher;
|
|
2119
2912
|
}
|
|
2120
2913
|
if (typeof origin !== "string") {
|
|
2121
2914
|
const dispatcher = this[kFactory]("http://localhost:9999");
|
|
2122
2915
|
this[kMockAgentSet](origin, dispatcher);
|
|
2123
2916
|
return dispatcher;
|
|
2124
2917
|
}
|
|
2125
|
-
for (const [keyMatcher,
|
|
2126
|
-
|
|
2127
|
-
if (nonExplicitDispatcher && typeof keyMatcher !== "string" && matchValue(keyMatcher, origin)) {
|
|
2918
|
+
for (const [keyMatcher, result2] of Array.from(this[kClients2])) {
|
|
2919
|
+
if (result2 && typeof keyMatcher !== "string" && matchValue(keyMatcher, origin)) {
|
|
2128
2920
|
const dispatcher = this[kFactory](origin);
|
|
2129
2921
|
this[kMockAgentSet](origin, dispatcher);
|
|
2130
|
-
dispatcher[kDispatches2] =
|
|
2922
|
+
dispatcher[kDispatches2] = result2.dispatcher[kDispatches2];
|
|
2131
2923
|
return dispatcher;
|
|
2132
2924
|
}
|
|
2133
2925
|
}
|
|
@@ -2137,19 +2929,20 @@ var require_mock_agent = __commonJS({
|
|
|
2137
2929
|
}
|
|
2138
2930
|
pendingInterceptors() {
|
|
2139
2931
|
const mockAgentClients = this[kClients2];
|
|
2140
|
-
return Array.from(mockAgentClients.entries()).flatMap(([origin,
|
|
2932
|
+
return Array.from(mockAgentClients.entries()).flatMap(([origin, result]) => result.dispatcher[kDispatches2].map((dispatch) => ({ ...dispatch, origin }))).filter(({ pending }) => pending);
|
|
2141
2933
|
}
|
|
2142
2934
|
assertNoPendingInterceptors({ pendingInterceptorsFormatter = new PendingInterceptorsFormatter() } = {}) {
|
|
2143
2935
|
const pending = this.pendingInterceptors();
|
|
2144
2936
|
if (pending.length === 0) {
|
|
2145
2937
|
return;
|
|
2146
2938
|
}
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
${pluralizer.count} ${pluralizer.noun} ${pluralizer.is} pending:
|
|
2939
|
+
throw new UndiciError(
|
|
2940
|
+
pending.length === 1 ? `1 interceptor is pending:
|
|
2150
2941
|
|
|
2151
|
-
${pendingInterceptorsFormatter.format(pending)}
|
|
2152
|
-
|
|
2942
|
+
${pendingInterceptorsFormatter.format(pending)}`.trim() : `${pending.length} interceptors are pending:
|
|
2943
|
+
|
|
2944
|
+
${pendingInterceptorsFormatter.format(pending)}`.trim()
|
|
2945
|
+
);
|
|
2153
2946
|
}
|
|
2154
2947
|
};
|
|
2155
2948
|
module2.exports = MockAgent2;
|
|
@@ -2170,7 +2963,7 @@ function resetMockAgent(agent) {
|
|
|
2170
2963
|
agent.deactivate();
|
|
2171
2964
|
agent.enableNetConnect();
|
|
2172
2965
|
for (const mockClient of agent[kClients].values()) {
|
|
2173
|
-
mockClient.
|
|
2966
|
+
mockClient.dispatcher?.[kDispatches].splice(0);
|
|
2174
2967
|
}
|
|
2175
2968
|
agent.assertNoPendingInterceptors();
|
|
2176
2969
|
}
|