auditjs
Version:
Audit dependencies to identify known vulnerabilities and maintenance problems
51 lines • 1.99 kB
JavaScript
;
/*
* Copyright 2019-Present Sonatype Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RequestHelpers = void 0;
const os_1 = __importDefault(require("os"));
const https_1 = require("https");
const https_proxy_agent_1 = require("https-proxy-agent");
const pack = require('../../package.json');
class RequestHelpers {
static getUserAgent() {
const nodeVersion = process.versions;
const environment = 'NodeJS';
const environmentVersion = nodeVersion.node;
const system = `${os_1.default.type()} ${os_1.default.release()}`;
return ['User-Agent', `AuditJS/${pack.version} (${environment} ${environmentVersion}; ${system})`];
}
static getAgent(insecure = false) {
if (insecure) {
return new https_1.Agent({
rejectUnauthorized: false,
});
}
return this.getHttpAgent();
}
static getHttpAgent() {
const proxyUrl = process.env.http_proxy || process.env.https_proxy;
if (proxyUrl !== undefined && proxyUrl !== 'no-proxy') {
return new https_proxy_agent_1.HttpsProxyAgent(proxyUrl);
}
return undefined;
}
}
exports.RequestHelpers = RequestHelpers;
//# sourceMappingURL=RequestHelpers.js.map