- npm upgrade
This commit is contained in:
+32
-27
@@ -10661,42 +10661,46 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Agent = void 0;
|
||||
const http = __importStar(__nccwpck_require__(3685));
|
||||
__exportStar(__nccwpck_require__(8348), exports);
|
||||
function isSecureEndpoint() {
|
||||
const { stack } = new Error();
|
||||
if (typeof stack !== 'string')
|
||||
return false;
|
||||
return stack
|
||||
.split('\n')
|
||||
.some((l) => l.indexOf('(https.js:') !== -1 ||
|
||||
l.indexOf('node:https:') !== -1);
|
||||
}
|
||||
const INTERNAL = Symbol('AgentBaseInternalState');
|
||||
class Agent extends http.Agent {
|
||||
constructor(opts) {
|
||||
super(opts);
|
||||
this[INTERNAL] = {};
|
||||
}
|
||||
createSocket(req, options, cb) {
|
||||
// Need to determine whether this is an `http` or `https` request.
|
||||
// First check the `secureEndpoint` property explicitly, since this
|
||||
// means that a parent `Agent` is "passing through" to this instance.
|
||||
let secureEndpoint = typeof options.secureEndpoint === 'boolean'
|
||||
? options.secureEndpoint
|
||||
: undefined;
|
||||
// If no explicit `secure` endpoint, check if `protocol` property is
|
||||
// set. This will usually be the case since using a full string URL
|
||||
// or `URL` instance should be the most common case.
|
||||
if (typeof secureEndpoint === 'undefined' &&
|
||||
typeof options.protocol === 'string') {
|
||||
secureEndpoint = options.protocol === 'https:';
|
||||
/**
|
||||
* Determine whether this is an `http` or `https` request.
|
||||
*/
|
||||
isSecureEndpoint(options) {
|
||||
if (options) {
|
||||
// First check the `secureEndpoint` property explicitly, since this
|
||||
// means that a parent `Agent` is "passing through" to this instance.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
if (typeof options.secureEndpoint === 'boolean') {
|
||||
return options.secureEndpoint;
|
||||
}
|
||||
// If no explicit `secure` endpoint, check if `protocol` property is
|
||||
// set. This will usually be the case since using a full string URL
|
||||
// or `URL` instance should be the most common usage.
|
||||
if (typeof options.protocol === 'string') {
|
||||
return options.protocol === 'https:';
|
||||
}
|
||||
}
|
||||
// Finally, if no `protocol` property was set, then fall back to
|
||||
// checking the stack trace of the current call stack, and try to
|
||||
// detect the "https" module.
|
||||
if (typeof secureEndpoint === 'undefined') {
|
||||
secureEndpoint = isSecureEndpoint();
|
||||
}
|
||||
const connectOpts = { ...options, secureEndpoint };
|
||||
const { stack } = new Error();
|
||||
if (typeof stack !== 'string')
|
||||
return false;
|
||||
return stack
|
||||
.split('\n')
|
||||
.some((l) => l.indexOf('(https.js:') !== -1 ||
|
||||
l.indexOf('node:https:') !== -1);
|
||||
}
|
||||
createSocket(req, options, cb) {
|
||||
const connectOpts = {
|
||||
...options,
|
||||
secureEndpoint: this.isSecureEndpoint(options),
|
||||
};
|
||||
Promise.resolve()
|
||||
.then(() => this.connect(req, connectOpts))
|
||||
.then((socket) => {
|
||||
@@ -10727,7 +10731,8 @@ class Agent extends http.Agent {
|
||||
}
|
||||
}
|
||||
get protocol() {
|
||||
return (this[INTERNAL].protocol ?? (isSecureEndpoint() ? 'https:' : 'http:'));
|
||||
return (this[INTERNAL].protocol ??
|
||||
(this.isSecureEndpoint() ? 'https:' : 'http:'));
|
||||
}
|
||||
set protocol(v) {
|
||||
if (this[INTERNAL]) {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user