You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@yarnpkg/core

Package Overview
Dependencies
Maintainers
5
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yarnpkg/core - npm Package Compare versions

Comparing version

to
4.4.2

2

lib/Configuration.d.ts

@@ -51,2 +51,4 @@ import { Filename, PortablePath } from '@yarnpkg/fslib';

readonly NUMBER: "NUMBER";
readonly STRING: "STRING";
readonly BOOLEAN: "BOOLEAN";
readonly PATH: "PATH";

@@ -53,0 +55,0 @@ readonly URL: "URL";

@@ -16,2 +16,4 @@ import { ColorFormat } from 'clipanion';

readonly NUMBER: "NUMBER";
readonly STRING: "STRING";
readonly BOOLEAN: "BOOLEAN";
readonly PATH: "PATH";

@@ -18,0 +20,0 @@ readonly URL: "URL";

@@ -24,3 +24,2 @@ "use strict";

exports.stripAnsi = strip_ansi_1.default;
const util_1 = require("util");
const MessageName_1 = require("./MessageName");

@@ -45,2 +44,4 @@ const miscUtils = tslib_1.__importStar(require("./miscUtils"));

NUMBER: `NUMBER`,
STRING: `STRING`,
BOOLEAN: `BOOLEAN`,
PATH: `PATH`,

@@ -85,2 +86,4 @@ URL: `URL`,

[exports.Type.NUMBER, [`#ffd700`, 220]],
[exports.Type.STRING, [`#b4bd68`, 32]],
[exports.Type.BOOLEAN, [`#faa023`, 209]],
[exports.Type.PATH, [`#d75fd7`, 170]],

@@ -110,2 +113,32 @@ [exports.Type.URL, [`#d75fd7`, 170]],

}
function prettyObject(configuration, value) {
if (Array.isArray(value)) {
if (value.length === 0) {
return applyColor(configuration, `[]`, exports.Type.CODE);
}
else {
return applyColor(configuration, `[ `, exports.Type.CODE) + value.map(item => prettyObject(configuration, item)).join(`, `) + applyColor(configuration, ` ]`, exports.Type.CODE);
}
}
if (typeof value === `string`)
return applyColor(configuration, JSON.stringify(value), exports.Type.STRING);
if (typeof value === `number`)
return applyColor(configuration, JSON.stringify(value), exports.Type.NUMBER);
if (typeof value === `boolean`)
return applyColor(configuration, JSON.stringify(value), exports.Type.BOOLEAN);
if (value === null)
return applyColor(configuration, `null`, exports.Type.NULL);
if (typeof value === `object` && Object.getPrototypeOf(value) === Object.prototype) {
const entries = Object.entries(value);
if (entries.length === 0) {
return applyColor(configuration, `{}`, exports.Type.CODE);
}
else {
return applyColor(configuration, `{ `, exports.Type.CODE) + entries.map(([key, value]) => `${prettyObject(configuration, key)}: ${prettyObject(configuration, value)}`).join(`, `) + applyColor(configuration, ` }`, exports.Type.CODE);
}
}
if (typeof value === `undefined`)
return applyColor(configuration, `undefined`, exports.Type.NULL);
throw new Error(`Assertion failed: The value doesn't seem to be a valid JSON object`);
}
const transforms = {

@@ -127,3 +160,3 @@ [exports.Type.ID]: validateTransform({

pretty: (configuration, value) => {
return (0, util_1.inspect)(value, { depth: Infinity, colors: configuration.get(`enableColors`), compact: true, breakLength: Infinity });
return prettyObject(configuration, value);
},

@@ -130,0 +163,0 @@ json: (value) => {

44

lib/httpUtils.js

@@ -12,6 +12,6 @@ "use strict";

const fslib_1 = require("@yarnpkg/fslib");
const hpagent_1 = require("hpagent");
const https_1 = require("https");
const http_1 = require("http");
const micromatch_1 = tslib_1.__importDefault(require("micromatch"));
const tunnel_1 = tslib_1.__importDefault(require("tunnel"));
const MessageName_1 = require("./MessageName");

@@ -25,11 +25,2 @@ const Report_1 = require("./Report");

const globalHttpsAgent = new https_1.Agent({ keepAlive: true });
function parseProxy(specifier) {
const url = new URL(specifier);
const proxy = { host: url.hostname, headers: {} };
if (url.port)
proxy.port = Number(url.port);
if (url.username && url.password)
proxy.proxyAuth = `${url.username}:${url.password}`;
return { proxy };
}
async function getCachedFile(filePath) {

@@ -190,11 +181,3 @@ return miscUtils.getFactoryWithDefault(fileCache, filePath, () => {

throw new Report_1.ReportError(MessageName_1.MessageName.NETWORK_UNSAFE_HTTP, `Unsafe http requests must be explicitly whitelisted in your configuration (${url.hostname})`);
const agent = {
http: networkConfig.httpProxy
? tunnel_1.default.httpOverHttp(parseProxy(networkConfig.httpProxy))
: globalHttpAgent,
https: networkConfig.httpsProxy
? tunnel_1.default.httpsOverHttp(parseProxy(networkConfig.httpsProxy))
: globalHttpsAgent,
};
const gotOptions = { agent, headers, method };
const gotOptions = { headers, method };
gotOptions.responseType = jsonResponse

@@ -228,2 +211,24 @@ ? `json`

: undefined;
const proxyRequestOptions = {
rejectUnauthorized,
ca: certificateAuthority,
cert: certificate,
key,
};
const agent = {
http: networkConfig.httpProxy
? new hpagent_1.HttpProxyAgent({
proxy: networkConfig.httpProxy,
// @ts-expect-error: hpagent actually supports all RequestOptions, but the types don't reflect that
proxyRequestOptions,
})
: globalHttpAgent,
https: networkConfig.httpsProxy
? new hpagent_1.HttpsProxyAgent({
proxy: networkConfig.httpsProxy,
// @ts-expect-error: hpagent actually supports all RequestOptions, but the types don't reflect that
proxyRequestOptions,
})
: globalHttpsAgent,
};
const gotClient = got.extend({

@@ -234,2 +239,3 @@ timeout: {

retry,
agent,
https: {

@@ -236,0 +242,0 @@ rejectUnauthorized,

@@ -418,2 +418,4 @@ "use strict";

this.publishConfig.registry = data.publishConfig.registry;
if (typeof data.publishConfig.provenance === `boolean`)
this.publishConfig.provenance = data.publishConfig.provenance;
if (typeof data.publishConfig.bin === `string`) {

@@ -420,0 +422,0 @@ if (this.name !== null) {

{
"name": "@yarnpkg/core",
"version": "4.4.1",
"version": "4.4.2",
"license": "BSD-2-Clause",

@@ -20,5 +20,5 @@ "main": "./lib/index.js",

"@yarnpkg/parsers": "^3.0.3",
"@yarnpkg/shell": "^4.1.2",
"@yarnpkg/shell": "^4.1.3",
"camelcase": "^5.3.1",
"chalk": "^3.0.0",
"chalk": "^4.1.2",
"ci-info": "^4.0.0",

@@ -31,2 +31,3 @@ "clipanion": "^4.0.0-rc.2",

"got": "^11.7.0",
"hpagent": "^1.2.0",
"lodash": "^4.17.15",

@@ -40,4 +41,3 @@ "micromatch": "^4.0.2",

"treeify": "^1.1.0",
"tslib": "^2.4.0",
"tunnel": "^0.0.6"
"tslib": "^2.4.0"
},

@@ -56,7 +56,6 @@ "devDependencies": {

"@types/tar": "^4.0.4",
"@types/tunnel": "^0.0.0",
"@yarnpkg/cli": "^4.9.1",
"@yarnpkg/plugin-link": "^3.0.1",
"@yarnpkg/plugin-npm": "^3.1.1",
"@yarnpkg/plugin-pnp": "^4.1.0",
"@yarnpkg/cli": "^4.9.2",
"@yarnpkg/plugin-link": "^3.0.2",
"@yarnpkg/plugin-npm": "^3.1.2",
"@yarnpkg/plugin-pnp": "^4.1.1",
"comment-json": "^2.2.0",

@@ -63,0 +62,0 @@ "esbuild": "npm:esbuild-wasm@^0.23.0",

Sorry, the diff of this file is too big to display