@spfunctions/cli 1.7.39 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/101.index.js +1 -451
- package/dist/12.index.js +1 -536
- package/dist/160.index.js +1 -709
- package/dist/174.index.js +1 -44
- package/dist/278.index.js +2 -15129
- package/dist/582.index.js +1 -1066
- package/dist/641.index.js +67 -122146
- package/dist/669.index.js +1 -556
- package/dist/722.index.js +1 -843
- package/dist/788.index.js +1 -6677
- package/dist/816.index.js +4 -7496
- package/dist/830.index.js +1 -1199
- package/dist/921.index.js +1 -10683
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/package.json +0 -52
package/dist/669.index.js
CHANGED
|
@@ -1,556 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.id = 669;
|
|
3
|
-
exports.ids = [669];
|
|
4
|
-
exports.modules = {
|
|
5
|
-
|
|
6
|
-
/***/ 15183:
|
|
7
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
-
}
|
|
16
|
-
Object.defineProperty(o, k2, desc);
|
|
17
|
-
}) : (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
o[k2] = m[k];
|
|
20
|
-
}));
|
|
21
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
-
}) : function(o, v) {
|
|
24
|
-
o["default"] = v;
|
|
25
|
-
});
|
|
26
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
27
|
-
if (mod && mod.__esModule) return mod;
|
|
28
|
-
var result = {};
|
|
29
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
30
|
-
__setModuleDefault(result, mod);
|
|
31
|
-
return result;
|
|
32
|
-
};
|
|
33
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
34
|
-
exports.req = exports.json = exports.toBuffer = void 0;
|
|
35
|
-
const http = __importStar(__webpack_require__(58611));
|
|
36
|
-
const https = __importStar(__webpack_require__(65692));
|
|
37
|
-
async function toBuffer(stream) {
|
|
38
|
-
let length = 0;
|
|
39
|
-
const chunks = [];
|
|
40
|
-
for await (const chunk of stream) {
|
|
41
|
-
length += chunk.length;
|
|
42
|
-
chunks.push(chunk);
|
|
43
|
-
}
|
|
44
|
-
return Buffer.concat(chunks, length);
|
|
45
|
-
}
|
|
46
|
-
exports.toBuffer = toBuffer;
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
-
async function json(stream) {
|
|
49
|
-
const buf = await toBuffer(stream);
|
|
50
|
-
const str = buf.toString('utf8');
|
|
51
|
-
try {
|
|
52
|
-
return JSON.parse(str);
|
|
53
|
-
}
|
|
54
|
-
catch (_err) {
|
|
55
|
-
const err = _err;
|
|
56
|
-
err.message += ` (input: ${str})`;
|
|
57
|
-
throw err;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.json = json;
|
|
61
|
-
function req(url, opts = {}) {
|
|
62
|
-
const href = typeof url === 'string' ? url : url.href;
|
|
63
|
-
const req = (href.startsWith('https:') ? https : http).request(url, opts);
|
|
64
|
-
const promise = new Promise((resolve, reject) => {
|
|
65
|
-
req
|
|
66
|
-
.once('response', resolve)
|
|
67
|
-
.once('error', reject)
|
|
68
|
-
.end();
|
|
69
|
-
});
|
|
70
|
-
req.then = promise.then.bind(promise);
|
|
71
|
-
return req;
|
|
72
|
-
}
|
|
73
|
-
exports.req = req;
|
|
74
|
-
//# sourceMappingURL=helpers.js.map
|
|
75
|
-
|
|
76
|
-
/***/ }),
|
|
77
|
-
|
|
78
|
-
/***/ 98894:
|
|
79
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
83
|
-
if (k2 === undefined) k2 = k;
|
|
84
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
85
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
86
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
87
|
-
}
|
|
88
|
-
Object.defineProperty(o, k2, desc);
|
|
89
|
-
}) : (function(o, m, k, k2) {
|
|
90
|
-
if (k2 === undefined) k2 = k;
|
|
91
|
-
o[k2] = m[k];
|
|
92
|
-
}));
|
|
93
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
94
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
95
|
-
}) : function(o, v) {
|
|
96
|
-
o["default"] = v;
|
|
97
|
-
});
|
|
98
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
99
|
-
if (mod && mod.__esModule) return mod;
|
|
100
|
-
var result = {};
|
|
101
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
102
|
-
__setModuleDefault(result, mod);
|
|
103
|
-
return result;
|
|
104
|
-
};
|
|
105
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
106
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
107
|
-
};
|
|
108
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
109
|
-
exports.Agent = void 0;
|
|
110
|
-
const net = __importStar(__webpack_require__(69278));
|
|
111
|
-
const http = __importStar(__webpack_require__(58611));
|
|
112
|
-
const https_1 = __webpack_require__(65692);
|
|
113
|
-
__exportStar(__webpack_require__(15183), exports);
|
|
114
|
-
const INTERNAL = Symbol('AgentBaseInternalState');
|
|
115
|
-
class Agent extends http.Agent {
|
|
116
|
-
constructor(opts) {
|
|
117
|
-
super(opts);
|
|
118
|
-
this[INTERNAL] = {};
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Determine whether this is an `http` or `https` request.
|
|
122
|
-
*/
|
|
123
|
-
isSecureEndpoint(options) {
|
|
124
|
-
if (options) {
|
|
125
|
-
// First check the `secureEndpoint` property explicitly, since this
|
|
126
|
-
// means that a parent `Agent` is "passing through" to this instance.
|
|
127
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
-
if (typeof options.secureEndpoint === 'boolean') {
|
|
129
|
-
return options.secureEndpoint;
|
|
130
|
-
}
|
|
131
|
-
// If no explicit `secure` endpoint, check if `protocol` property is
|
|
132
|
-
// set. This will usually be the case since using a full string URL
|
|
133
|
-
// or `URL` instance should be the most common usage.
|
|
134
|
-
if (typeof options.protocol === 'string') {
|
|
135
|
-
return options.protocol === 'https:';
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
// Finally, if no `protocol` property was set, then fall back to
|
|
139
|
-
// checking the stack trace of the current call stack, and try to
|
|
140
|
-
// detect the "https" module.
|
|
141
|
-
const { stack } = new Error();
|
|
142
|
-
if (typeof stack !== 'string')
|
|
143
|
-
return false;
|
|
144
|
-
return stack
|
|
145
|
-
.split('\n')
|
|
146
|
-
.some((l) => l.indexOf('(https.js:') !== -1 ||
|
|
147
|
-
l.indexOf('node:https:') !== -1);
|
|
148
|
-
}
|
|
149
|
-
// In order to support async signatures in `connect()` and Node's native
|
|
150
|
-
// connection pooling in `http.Agent`, the array of sockets for each origin
|
|
151
|
-
// has to be updated synchronously. This is so the length of the array is
|
|
152
|
-
// accurate when `addRequest()` is next called. We achieve this by creating a
|
|
153
|
-
// fake socket and adding it to `sockets[origin]` and incrementing
|
|
154
|
-
// `totalSocketCount`.
|
|
155
|
-
incrementSockets(name) {
|
|
156
|
-
// If `maxSockets` and `maxTotalSockets` are both Infinity then there is no
|
|
157
|
-
// need to create a fake socket because Node.js native connection pooling
|
|
158
|
-
// will never be invoked.
|
|
159
|
-
if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) {
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
// All instances of `sockets` are expected TypeScript errors. The
|
|
163
|
-
// alternative is to add it as a private property of this class but that
|
|
164
|
-
// will break TypeScript subclassing.
|
|
165
|
-
if (!this.sockets[name]) {
|
|
166
|
-
// @ts-expect-error `sockets` is readonly in `@types/node`
|
|
167
|
-
this.sockets[name] = [];
|
|
168
|
-
}
|
|
169
|
-
const fakeSocket = new net.Socket({ writable: false });
|
|
170
|
-
this.sockets[name].push(fakeSocket);
|
|
171
|
-
// @ts-expect-error `totalSocketCount` isn't defined in `@types/node`
|
|
172
|
-
this.totalSocketCount++;
|
|
173
|
-
return fakeSocket;
|
|
174
|
-
}
|
|
175
|
-
decrementSockets(name, socket) {
|
|
176
|
-
if (!this.sockets[name] || socket === null) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
const sockets = this.sockets[name];
|
|
180
|
-
const index = sockets.indexOf(socket);
|
|
181
|
-
if (index !== -1) {
|
|
182
|
-
sockets.splice(index, 1);
|
|
183
|
-
// @ts-expect-error `totalSocketCount` isn't defined in `@types/node`
|
|
184
|
-
this.totalSocketCount--;
|
|
185
|
-
if (sockets.length === 0) {
|
|
186
|
-
// @ts-expect-error `sockets` is readonly in `@types/node`
|
|
187
|
-
delete this.sockets[name];
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
// In order to properly update the socket pool, we need to call `getName()` on
|
|
192
|
-
// the core `https.Agent` if it is a secureEndpoint.
|
|
193
|
-
getName(options) {
|
|
194
|
-
const secureEndpoint = this.isSecureEndpoint(options);
|
|
195
|
-
if (secureEndpoint) {
|
|
196
|
-
// @ts-expect-error `getName()` isn't defined in `@types/node`
|
|
197
|
-
return https_1.Agent.prototype.getName.call(this, options);
|
|
198
|
-
}
|
|
199
|
-
// @ts-expect-error `getName()` isn't defined in `@types/node`
|
|
200
|
-
return super.getName(options);
|
|
201
|
-
}
|
|
202
|
-
createSocket(req, options, cb) {
|
|
203
|
-
const connectOpts = {
|
|
204
|
-
...options,
|
|
205
|
-
secureEndpoint: this.isSecureEndpoint(options),
|
|
206
|
-
};
|
|
207
|
-
const name = this.getName(connectOpts);
|
|
208
|
-
const fakeSocket = this.incrementSockets(name);
|
|
209
|
-
Promise.resolve()
|
|
210
|
-
.then(() => this.connect(req, connectOpts))
|
|
211
|
-
.then((socket) => {
|
|
212
|
-
this.decrementSockets(name, fakeSocket);
|
|
213
|
-
if (socket instanceof http.Agent) {
|
|
214
|
-
try {
|
|
215
|
-
// @ts-expect-error `addRequest()` isn't defined in `@types/node`
|
|
216
|
-
return socket.addRequest(req, connectOpts);
|
|
217
|
-
}
|
|
218
|
-
catch (err) {
|
|
219
|
-
return cb(err);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
this[INTERNAL].currentSocket = socket;
|
|
223
|
-
// @ts-expect-error `createSocket()` isn't defined in `@types/node`
|
|
224
|
-
super.createSocket(req, options, cb);
|
|
225
|
-
}, (err) => {
|
|
226
|
-
this.decrementSockets(name, fakeSocket);
|
|
227
|
-
cb(err);
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
createConnection() {
|
|
231
|
-
const socket = this[INTERNAL].currentSocket;
|
|
232
|
-
this[INTERNAL].currentSocket = undefined;
|
|
233
|
-
if (!socket) {
|
|
234
|
-
throw new Error('No socket was returned in the `connect()` function');
|
|
235
|
-
}
|
|
236
|
-
return socket;
|
|
237
|
-
}
|
|
238
|
-
get defaultPort() {
|
|
239
|
-
return (this[INTERNAL].defaultPort ??
|
|
240
|
-
(this.protocol === 'https:' ? 443 : 80));
|
|
241
|
-
}
|
|
242
|
-
set defaultPort(v) {
|
|
243
|
-
if (this[INTERNAL]) {
|
|
244
|
-
this[INTERNAL].defaultPort = v;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
get protocol() {
|
|
248
|
-
return (this[INTERNAL].protocol ??
|
|
249
|
-
(this.isSecureEndpoint() ? 'https:' : 'http:'));
|
|
250
|
-
}
|
|
251
|
-
set protocol(v) {
|
|
252
|
-
if (this[INTERNAL]) {
|
|
253
|
-
this[INTERNAL].protocol = v;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
exports.Agent = Agent;
|
|
258
|
-
//# sourceMappingURL=index.js.map
|
|
259
|
-
|
|
260
|
-
/***/ }),
|
|
261
|
-
|
|
262
|
-
/***/ 3669:
|
|
263
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
267
|
-
if (k2 === undefined) k2 = k;
|
|
268
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
269
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
270
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
271
|
-
}
|
|
272
|
-
Object.defineProperty(o, k2, desc);
|
|
273
|
-
}) : (function(o, m, k, k2) {
|
|
274
|
-
if (k2 === undefined) k2 = k;
|
|
275
|
-
o[k2] = m[k];
|
|
276
|
-
}));
|
|
277
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
278
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
279
|
-
}) : function(o, v) {
|
|
280
|
-
o["default"] = v;
|
|
281
|
-
});
|
|
282
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
283
|
-
if (mod && mod.__esModule) return mod;
|
|
284
|
-
var result = {};
|
|
285
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
286
|
-
__setModuleDefault(result, mod);
|
|
287
|
-
return result;
|
|
288
|
-
};
|
|
289
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
290
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
291
|
-
};
|
|
292
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
293
|
-
exports.HttpsProxyAgent = void 0;
|
|
294
|
-
const net = __importStar(__webpack_require__(69278));
|
|
295
|
-
const tls = __importStar(__webpack_require__(64756));
|
|
296
|
-
const assert_1 = __importDefault(__webpack_require__(42613));
|
|
297
|
-
const debug_1 = __importDefault(__webpack_require__(2830));
|
|
298
|
-
const agent_base_1 = __webpack_require__(98894);
|
|
299
|
-
const url_1 = __webpack_require__(87016);
|
|
300
|
-
const parse_proxy_response_1 = __webpack_require__(37943);
|
|
301
|
-
const debug = (0, debug_1.default)('https-proxy-agent');
|
|
302
|
-
const setServernameFromNonIpHost = (options) => {
|
|
303
|
-
if (options.servername === undefined &&
|
|
304
|
-
options.host &&
|
|
305
|
-
!net.isIP(options.host)) {
|
|
306
|
-
return {
|
|
307
|
-
...options,
|
|
308
|
-
servername: options.host,
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
return options;
|
|
312
|
-
};
|
|
313
|
-
/**
|
|
314
|
-
* The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
|
|
315
|
-
* the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
|
|
316
|
-
*
|
|
317
|
-
* Outgoing HTTP requests are first tunneled through the proxy server using the
|
|
318
|
-
* `CONNECT` HTTP request method to establish a connection to the proxy server,
|
|
319
|
-
* and then the proxy server connects to the destination target and issues the
|
|
320
|
-
* HTTP request from the proxy server.
|
|
321
|
-
*
|
|
322
|
-
* `https:` requests have their socket connection upgraded to TLS once
|
|
323
|
-
* the connection to the proxy server has been established.
|
|
324
|
-
*/
|
|
325
|
-
class HttpsProxyAgent extends agent_base_1.Agent {
|
|
326
|
-
constructor(proxy, opts) {
|
|
327
|
-
super(opts);
|
|
328
|
-
this.options = { path: undefined };
|
|
329
|
-
this.proxy = typeof proxy === 'string' ? new url_1.URL(proxy) : proxy;
|
|
330
|
-
this.proxyHeaders = opts?.headers ?? {};
|
|
331
|
-
debug('Creating new HttpsProxyAgent instance: %o', this.proxy.href);
|
|
332
|
-
// Trim off the brackets from IPv6 addresses
|
|
333
|
-
const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, '');
|
|
334
|
-
const port = this.proxy.port
|
|
335
|
-
? parseInt(this.proxy.port, 10)
|
|
336
|
-
: this.proxy.protocol === 'https:'
|
|
337
|
-
? 443
|
|
338
|
-
: 80;
|
|
339
|
-
this.connectOpts = {
|
|
340
|
-
// Attempt to negotiate http/1.1 for proxy servers that support http/2
|
|
341
|
-
ALPNProtocols: ['http/1.1'],
|
|
342
|
-
...(opts ? omit(opts, 'headers') : null),
|
|
343
|
-
host,
|
|
344
|
-
port,
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Called when the node-core HTTP client library is creating a
|
|
349
|
-
* new HTTP request.
|
|
350
|
-
*/
|
|
351
|
-
async connect(req, opts) {
|
|
352
|
-
const { proxy } = this;
|
|
353
|
-
if (!opts.host) {
|
|
354
|
-
throw new TypeError('No "host" provided');
|
|
355
|
-
}
|
|
356
|
-
// Create a socket connection to the proxy server.
|
|
357
|
-
let socket;
|
|
358
|
-
if (proxy.protocol === 'https:') {
|
|
359
|
-
debug('Creating `tls.Socket`: %o', this.connectOpts);
|
|
360
|
-
socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
debug('Creating `net.Socket`: %o', this.connectOpts);
|
|
364
|
-
socket = net.connect(this.connectOpts);
|
|
365
|
-
}
|
|
366
|
-
const headers = typeof this.proxyHeaders === 'function'
|
|
367
|
-
? this.proxyHeaders()
|
|
368
|
-
: { ...this.proxyHeaders };
|
|
369
|
-
const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
|
|
370
|
-
let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r\n`;
|
|
371
|
-
// Inject the `Proxy-Authorization` header if necessary.
|
|
372
|
-
if (proxy.username || proxy.password) {
|
|
373
|
-
const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
|
|
374
|
-
headers['Proxy-Authorization'] = `Basic ${Buffer.from(auth).toString('base64')}`;
|
|
375
|
-
}
|
|
376
|
-
headers.Host = `${host}:${opts.port}`;
|
|
377
|
-
if (!headers['Proxy-Connection']) {
|
|
378
|
-
headers['Proxy-Connection'] = this.keepAlive
|
|
379
|
-
? 'Keep-Alive'
|
|
380
|
-
: 'close';
|
|
381
|
-
}
|
|
382
|
-
for (const name of Object.keys(headers)) {
|
|
383
|
-
payload += `${name}: ${headers[name]}\r\n`;
|
|
384
|
-
}
|
|
385
|
-
const proxyResponsePromise = (0, parse_proxy_response_1.parseProxyResponse)(socket);
|
|
386
|
-
socket.write(`${payload}\r\n`);
|
|
387
|
-
const { connect, buffered } = await proxyResponsePromise;
|
|
388
|
-
req.emit('proxyConnect', connect);
|
|
389
|
-
this.emit('proxyConnect', connect, req);
|
|
390
|
-
if (connect.statusCode === 200) {
|
|
391
|
-
req.once('socket', resume);
|
|
392
|
-
if (opts.secureEndpoint) {
|
|
393
|
-
// The proxy is connecting to a TLS server, so upgrade
|
|
394
|
-
// this socket connection to a TLS connection.
|
|
395
|
-
debug('Upgrading socket connection to TLS');
|
|
396
|
-
return tls.connect({
|
|
397
|
-
...omit(setServernameFromNonIpHost(opts), 'host', 'path', 'port'),
|
|
398
|
-
socket,
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
return socket;
|
|
402
|
-
}
|
|
403
|
-
// Some other status code that's not 200... need to re-play the HTTP
|
|
404
|
-
// header "data" events onto the socket once the HTTP machinery is
|
|
405
|
-
// attached so that the node core `http` can parse and handle the
|
|
406
|
-
// error status code.
|
|
407
|
-
// Close the original socket, and a new "fake" socket is returned
|
|
408
|
-
// instead, so that the proxy doesn't get the HTTP request
|
|
409
|
-
// written to it (which may contain `Authorization` headers or other
|
|
410
|
-
// sensitive data).
|
|
411
|
-
//
|
|
412
|
-
// See: https://hackerone.com/reports/541502
|
|
413
|
-
socket.destroy();
|
|
414
|
-
const fakeSocket = new net.Socket({ writable: false });
|
|
415
|
-
fakeSocket.readable = true;
|
|
416
|
-
// Need to wait for the "socket" event to re-play the "data" events.
|
|
417
|
-
req.once('socket', (s) => {
|
|
418
|
-
debug('Replaying proxy buffer for failed request');
|
|
419
|
-
(0, assert_1.default)(s.listenerCount('data') > 0);
|
|
420
|
-
// Replay the "buffered" Buffer onto the fake `socket`, since at
|
|
421
|
-
// this point the HTTP module machinery has been hooked up for
|
|
422
|
-
// the user.
|
|
423
|
-
s.push(buffered);
|
|
424
|
-
s.push(null);
|
|
425
|
-
});
|
|
426
|
-
return fakeSocket;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
HttpsProxyAgent.protocols = ['http', 'https'];
|
|
430
|
-
exports.HttpsProxyAgent = HttpsProxyAgent;
|
|
431
|
-
function resume(socket) {
|
|
432
|
-
socket.resume();
|
|
433
|
-
}
|
|
434
|
-
function omit(obj, ...keys) {
|
|
435
|
-
const ret = {};
|
|
436
|
-
let key;
|
|
437
|
-
for (key in obj) {
|
|
438
|
-
if (!keys.includes(key)) {
|
|
439
|
-
ret[key] = obj[key];
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
return ret;
|
|
443
|
-
}
|
|
444
|
-
//# sourceMappingURL=index.js.map
|
|
445
|
-
|
|
446
|
-
/***/ }),
|
|
447
|
-
|
|
448
|
-
/***/ 37943:
|
|
449
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
453
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
454
|
-
};
|
|
455
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
456
|
-
exports.parseProxyResponse = void 0;
|
|
457
|
-
const debug_1 = __importDefault(__webpack_require__(2830));
|
|
458
|
-
const debug = (0, debug_1.default)('https-proxy-agent:parse-proxy-response');
|
|
459
|
-
function parseProxyResponse(socket) {
|
|
460
|
-
return new Promise((resolve, reject) => {
|
|
461
|
-
// we need to buffer any HTTP traffic that happens with the proxy before we get
|
|
462
|
-
// the CONNECT response, so that if the response is anything other than an "200"
|
|
463
|
-
// response code, then we can re-play the "data" events on the socket once the
|
|
464
|
-
// HTTP parser is hooked up...
|
|
465
|
-
let buffersLength = 0;
|
|
466
|
-
const buffers = [];
|
|
467
|
-
function read() {
|
|
468
|
-
const b = socket.read();
|
|
469
|
-
if (b)
|
|
470
|
-
ondata(b);
|
|
471
|
-
else
|
|
472
|
-
socket.once('readable', read);
|
|
473
|
-
}
|
|
474
|
-
function cleanup() {
|
|
475
|
-
socket.removeListener('end', onend);
|
|
476
|
-
socket.removeListener('error', onerror);
|
|
477
|
-
socket.removeListener('readable', read);
|
|
478
|
-
}
|
|
479
|
-
function onend() {
|
|
480
|
-
cleanup();
|
|
481
|
-
debug('onend');
|
|
482
|
-
reject(new Error('Proxy connection ended before receiving CONNECT response'));
|
|
483
|
-
}
|
|
484
|
-
function onerror(err) {
|
|
485
|
-
cleanup();
|
|
486
|
-
debug('onerror %o', err);
|
|
487
|
-
reject(err);
|
|
488
|
-
}
|
|
489
|
-
function ondata(b) {
|
|
490
|
-
buffers.push(b);
|
|
491
|
-
buffersLength += b.length;
|
|
492
|
-
const buffered = Buffer.concat(buffers, buffersLength);
|
|
493
|
-
const endOfHeaders = buffered.indexOf('\r\n\r\n');
|
|
494
|
-
if (endOfHeaders === -1) {
|
|
495
|
-
// keep buffering
|
|
496
|
-
debug('have not received end of HTTP headers yet...');
|
|
497
|
-
read();
|
|
498
|
-
return;
|
|
499
|
-
}
|
|
500
|
-
const headerParts = buffered
|
|
501
|
-
.slice(0, endOfHeaders)
|
|
502
|
-
.toString('ascii')
|
|
503
|
-
.split('\r\n');
|
|
504
|
-
const firstLine = headerParts.shift();
|
|
505
|
-
if (!firstLine) {
|
|
506
|
-
socket.destroy();
|
|
507
|
-
return reject(new Error('No header received from proxy CONNECT response'));
|
|
508
|
-
}
|
|
509
|
-
const firstLineParts = firstLine.split(' ');
|
|
510
|
-
const statusCode = +firstLineParts[1];
|
|
511
|
-
const statusText = firstLineParts.slice(2).join(' ');
|
|
512
|
-
const headers = {};
|
|
513
|
-
for (const header of headerParts) {
|
|
514
|
-
if (!header)
|
|
515
|
-
continue;
|
|
516
|
-
const firstColon = header.indexOf(':');
|
|
517
|
-
if (firstColon === -1) {
|
|
518
|
-
socket.destroy();
|
|
519
|
-
return reject(new Error(`Invalid header from proxy CONNECT response: "${header}"`));
|
|
520
|
-
}
|
|
521
|
-
const key = header.slice(0, firstColon).toLowerCase();
|
|
522
|
-
const value = header.slice(firstColon + 1).trimStart();
|
|
523
|
-
const current = headers[key];
|
|
524
|
-
if (typeof current === 'string') {
|
|
525
|
-
headers[key] = [current, value];
|
|
526
|
-
}
|
|
527
|
-
else if (Array.isArray(current)) {
|
|
528
|
-
current.push(value);
|
|
529
|
-
}
|
|
530
|
-
else {
|
|
531
|
-
headers[key] = value;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
debug('got proxy server response: %o %o', firstLine, headers);
|
|
535
|
-
cleanup();
|
|
536
|
-
resolve({
|
|
537
|
-
connect: {
|
|
538
|
-
statusCode,
|
|
539
|
-
statusText,
|
|
540
|
-
headers,
|
|
541
|
-
},
|
|
542
|
-
buffered,
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
socket.on('error', onerror);
|
|
546
|
-
socket.on('end', onend);
|
|
547
|
-
read();
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
exports.parseProxyResponse = parseProxyResponse;
|
|
551
|
-
//# sourceMappingURL=parse-proxy-response.js.map
|
|
552
|
-
|
|
553
|
-
/***/ })
|
|
554
|
-
|
|
555
|
-
};
|
|
556
|
-
;
|
|
1
|
+
"use strict";exports.id=669,exports.ids=[669],exports.modules={15183:function(t,e,o){var r=this&&this.__createBinding||(Object.create?function(t,e,o,r){void 0===r&&(r=o);var n=Object.getOwnPropertyDescriptor(e,o);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,r,n)}:function(t,e,o,r){void 0===r&&(r=o),t[r]=e[o]}),n=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o in t)"default"!==o&&Object.prototype.hasOwnProperty.call(t,o)&&r(e,t,o);return n(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.req=e.json=e.toBuffer=void 0;const i=s(o(58611)),c=s(o(65692));async function u(t){let e=0;const o=[];for await(const r of t)e+=r.length,o.push(r);return Buffer.concat(o,e)}e.toBuffer=u,e.json=async function(t){const e=(await u(t)).toString("utf8");try{return JSON.parse(e)}catch(t){const o=t;throw o.message+=` (input: ${e})`,o}},e.req=function(t,e={}){const o=(("string"==typeof t?t:t.href).startsWith("https:")?c:i).request(t,e),r=new Promise((t,e)=>{o.once("response",t).once("error",e).end()});return o.then=r.then.bind(r),o}},98894:function(t,e,o){var r=this&&this.__createBinding||(Object.create?function(t,e,o,r){void 0===r&&(r=o);var n=Object.getOwnPropertyDescriptor(e,o);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,r,n)}:function(t,e,o,r){void 0===r&&(r=o),t[r]=e[o]}),n=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o in t)"default"!==o&&Object.prototype.hasOwnProperty.call(t,o)&&r(e,t,o);return n(e,t),e},i=this&&this.__exportStar||function(t,e){for(var o in t)"default"===o||Object.prototype.hasOwnProperty.call(e,o)||r(e,t,o)};Object.defineProperty(e,"__esModule",{value:!0}),e.Agent=void 0;const c=s(o(69278)),u=s(o(58611)),a=o(65692);i(o(15183),e);const p=Symbol("AgentBaseInternalState");class f extends u.Agent{constructor(t){super(t),this[p]={}}isSecureEndpoint(t){if(t){if("boolean"==typeof t.secureEndpoint)return t.secureEndpoint;if("string"==typeof t.protocol)return"https:"===t.protocol}const{stack:e}=new Error;return"string"==typeof e&&e.split("\n").some(t=>-1!==t.indexOf("(https.js:")||-1!==t.indexOf("node:https:"))}incrementSockets(t){if(this.maxSockets===1/0&&this.maxTotalSockets===1/0)return null;this.sockets[t]||(this.sockets[t]=[]);const e=new c.Socket({writable:!1});return this.sockets[t].push(e),this.totalSocketCount++,e}decrementSockets(t,e){if(!this.sockets[t]||null===e)return;const o=this.sockets[t],r=o.indexOf(e);-1!==r&&(o.splice(r,1),this.totalSocketCount--,0===o.length&&delete this.sockets[t])}getName(t){return this.isSecureEndpoint(t)?a.Agent.prototype.getName.call(this,t):super.getName(t)}createSocket(t,e,o){const r={...e,secureEndpoint:this.isSecureEndpoint(e)},n=this.getName(r),s=this.incrementSockets(n);Promise.resolve().then(()=>this.connect(t,r)).then(i=>{if(this.decrementSockets(n,s),i instanceof u.Agent)try{return i.addRequest(t,r)}catch(t){return o(t)}this[p].currentSocket=i,super.createSocket(t,e,o)},t=>{this.decrementSockets(n,s),o(t)})}createConnection(){const t=this[p].currentSocket;if(this[p].currentSocket=void 0,!t)throw new Error("No socket was returned in the `connect()` function");return t}get defaultPort(){return this[p].defaultPort??("https:"===this.protocol?443:80)}set defaultPort(t){this[p]&&(this[p].defaultPort=t)}get protocol(){return this[p].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(t){this[p]&&(this[p].protocol=t)}}e.Agent=f},3669:function(t,e,o){var r=this&&this.__createBinding||(Object.create?function(t,e,o,r){void 0===r&&(r=o);var n=Object.getOwnPropertyDescriptor(e,o);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,r,n)}:function(t,e,o,r){void 0===r&&(r=o),t[r]=e[o]}),n=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o in t)"default"!==o&&Object.prototype.hasOwnProperty.call(t,o)&&r(e,t,o);return n(e,t),e},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.HttpsProxyAgent=void 0;const c=s(o(69278)),u=s(o(64756)),a=i(o(42613)),p=i(o(2830)),f=o(98894),h=o(87016),l=o(37943),d=(0,p.default)("https-proxy-agent"),y=t=>void 0===t.servername&&t.host&&!c.isIP(t.host)?{...t,servername:t.host}:t;class g extends f.Agent{constructor(t,e){super(e),this.options={path:void 0},this.proxy="string"==typeof t?new h.URL(t):t,this.proxyHeaders=e?.headers??{},d("Creating new HttpsProxyAgent instance: %o",this.proxy.href);const o=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),r=this.proxy.port?parseInt(this.proxy.port,10):"https:"===this.proxy.protocol?443:80;this.connectOpts={ALPNProtocols:["http/1.1"],...e?b(e,"headers"):null,host:o,port:r}}async connect(t,e){const{proxy:o}=this;if(!e.host)throw new TypeError('No "host" provided');let r;"https:"===o.protocol?(d("Creating `tls.Socket`: %o",this.connectOpts),r=u.connect(y(this.connectOpts))):(d("Creating `net.Socket`: %o",this.connectOpts),r=c.connect(this.connectOpts));const n="function"==typeof this.proxyHeaders?this.proxyHeaders():{...this.proxyHeaders},s=c.isIPv6(e.host)?`[${e.host}]`:e.host;let i=`CONNECT ${s}:${e.port} HTTP/1.1\r\n`;if(o.username||o.password){const t=`${decodeURIComponent(o.username)}:${decodeURIComponent(o.password)}`;n["Proxy-Authorization"]=`Basic ${Buffer.from(t).toString("base64")}`}n.Host=`${s}:${e.port}`,n["Proxy-Connection"]||(n["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close");for(const t of Object.keys(n))i+=`${t}: ${n[t]}\r\n`;const p=(0,l.parseProxyResponse)(r);r.write(`${i}\r\n`);const{connect:f,buffered:h}=await p;if(t.emit("proxyConnect",f),this.emit("proxyConnect",f,t),200===f.statusCode)return t.once("socket",v),e.secureEndpoint?(d("Upgrading socket connection to TLS"),u.connect({...b(y(e),"host","path","port"),socket:r})):r;r.destroy();const g=new c.Socket({writable:!1});return g.readable=!0,t.once("socket",t=>{d("Replaying proxy buffer for failed request"),(0,a.default)(t.listenerCount("data")>0),t.push(h),t.push(null)}),g}}function v(t){t.resume()}function b(t,...e){const o={};let r;for(r in t)e.includes(r)||(o[r]=t[r]);return o}g.protocols=["http","https"],e.HttpsProxyAgent=g},37943:function(t,e,o){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.parseProxyResponse=void 0;const n=(0,r(o(2830)).default)("https-proxy-agent:parse-proxy-response");e.parseProxyResponse=function(t){return new Promise((e,o)=>{let r=0;const s=[];function i(){const u=t.read();u?function(u){s.push(u),r+=u.length;const a=Buffer.concat(s,r),p=a.indexOf("\r\n\r\n");if(-1===p)return n("have not received end of HTTP headers yet..."),void i();const f=a.slice(0,p).toString("ascii").split("\r\n"),h=f.shift();if(!h)return t.destroy(),o(new Error("No header received from proxy CONNECT response"));const l=h.split(" "),d=+l[1],y=l.slice(2).join(" "),g={};for(const e of f){if(!e)continue;const r=e.indexOf(":");if(-1===r)return t.destroy(),o(new Error(`Invalid header from proxy CONNECT response: "${e}"`));const n=e.slice(0,r).toLowerCase(),s=e.slice(r+1).trimStart(),i=g[n];"string"==typeof i?g[n]=[i,s]:Array.isArray(i)?i.push(s):g[n]=s}n("got proxy server response: %o %o",h,g),c(),e({connect:{statusCode:d,statusText:y,headers:g},buffered:a})}(u):t.once("readable",i)}function c(){t.removeListener("end",u),t.removeListener("error",a),t.removeListener("readable",i)}function u(){c(),n("onend"),o(new Error("Proxy connection ended before receiving CONNECT response"))}function a(t){c(),n("onerror %o",t),o(t)}t.on("error",a),t.on("end",u),i()})}}};
|