Socket
Socket
Sign inDemoInstall

@pnpm/server

Package Overview
Dependencies
Maintainers
3
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pnpm/server - npm Package Compare versions

Comparing version 3.0.0-0 to 3.0.0

40

lib/connectStoreController.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const got = require("got");
const fetch_1 = require("@pnpm/fetch");
const p_limit_1 = require("p-limit");

@@ -8,3 +8,3 @@ const uuid = require("uuid");

const remotePrefix = initOpts.remotePrefix;
const limitedFetch = fetch.bind(null, p_limit_1.default(initOpts.concurrency || 100));
const limitedFetch = limitFetch.bind(null, p_limit_1.default(initOpts.concurrency || 100));
return new Promise((resolve, reject) => {

@@ -55,21 +55,25 @@ resolve({

exports.default = default_1;
function fetch(limit, url, body) {
function limitFetch(limit, url, body) {
return limit(async () => {
try {
const response = await got(url, {
body: JSON.stringify(body),
headers: { 'Content-Type': 'application/json' },
method: 'POST',
retries: () => {
return 100;
},
});
if (!response.body) {
return undefined;
}
return JSON.parse(response.body);
// TODO: the http://unix: should be also supported by the fetcher
// but it fails with node-fetch-unix as of v2.3.0
if (url.startsWith('http://unix:')) {
url = url.replace('http://unix:', 'unix:');
}
catch (e) {
throw JSON.parse(e.response.body);
const response = await fetch_1.default(url, {
body: JSON.stringify(body),
headers: { 'Content-Type': 'application/json' },
method: 'POST',
retry: {
retries: 100,
},
});
if (!response.ok) {
throw await response.json();
}
const json = await response.json();
if (json.error) {
throw json.error;
}
return json;
});

@@ -76,0 +80,0 @@ }

@@ -42,24 +42,38 @@ "use strict";

case '/requestPackage': {
body = await bodyPromise;
const pkgResponse = await store.requestPackage(body.wantedDependency, body.options);
if (pkgResponse['fetchingRawManifest']) { // tslint:disable-line
rawManifestPromises[body.msgId] = pkgResponse['fetchingRawManifest']; // tslint:disable-line
pkgResponse.body['fetchingRawManifestInProgress'] = true; // tslint:disable-line
try {
body = await bodyPromise;
const pkgResponse = await store.requestPackage(body.wantedDependency, body.options);
if (pkgResponse['fetchingRawManifest']) { // tslint:disable-line
rawManifestPromises[body.msgId] = pkgResponse['fetchingRawManifest']; // tslint:disable-line
pkgResponse.body['fetchingRawManifestInProgress'] = true; // tslint:disable-line
}
if (pkgResponse['fetchingFiles']) { // tslint:disable-line
filesPromises[body.msgId] = pkgResponse['fetchingFiles']; // tslint:disable-line
}
res.end(JSON.stringify(pkgResponse.body));
}
if (pkgResponse['fetchingFiles']) { // tslint:disable-line
filesPromises[body.msgId] = pkgResponse['fetchingFiles']; // tslint:disable-line
catch (err) {
res.end(JSON.stringify({
error: Object.assign({ message: err.message }, JSON.parse(JSON.stringify(err))),
}));
}
res.end(JSON.stringify(pkgResponse.body));
break;
}
case '/fetchPackage': {
body = await bodyPromise;
const pkgResponse = store.fetchPackage(body.options);
if (pkgResponse['fetchingRawManifest']) { // tslint:disable-line
rawManifestPromises[body.msgId] = pkgResponse['fetchingRawManifest']; // tslint:disable-line
try {
body = await bodyPromise;
const pkgResponse = store.fetchPackage(body.options);
if (pkgResponse['fetchingRawManifest']) { // tslint:disable-line
rawManifestPromises[body.msgId] = pkgResponse['fetchingRawManifest']; // tslint:disable-line
}
if (pkgResponse['fetchingFiles']) { // tslint:disable-line
filesPromises[body.msgId] = pkgResponse['fetchingFiles']; // tslint:disable-line
}
res.end(JSON.stringify({ inStoreLocation: pkgResponse.inStoreLocation }));
}
if (pkgResponse['fetchingFiles']) { // tslint:disable-line
filesPromises[body.msgId] = pkgResponse['fetchingFiles']; // tslint:disable-line
catch (err) {
res.end(JSON.stringify({
error: Object.assign({ message: err.message }, JSON.parse(JSON.stringify(err))),
}));
}
res.end(JSON.stringify({ inStoreLocation: pkgResponse.inStoreLocation }));
break;

@@ -66,0 +80,0 @@ }

{
"name": "@pnpm/server",
"version": "3.0.0-0",
"version": "3.0.0",
"description": "A pnpm installer server",

@@ -36,9 +36,10 @@ "main": "lib/index.js",

"@pnpm/logger": "2.1.0",
"@pnpm/npm-resolver": "3.0.0-1",
"@pnpm/package-requester": "7.0.0-0",
"@pnpm/package-store": "4.0.0-0",
"@pnpm/npm-resolver": "3.0.0",
"@pnpm/package-requester": "7.0.0",
"@pnpm/package-store": "4.0.0",
"@pnpm/server": "link:",
"@pnpm/tarball-fetcher": "3.0.0-1",
"@pnpm/tarball-fetcher": "3.0.0",
"@pnpm/tslint-config": "0.0.0",
"@types/mz": "0.0.32",
"@types/node-fetch": "2.1.6",
"@types/tape": "4.2.33",

@@ -49,6 +50,7 @@ "is-port-reachable": "2.0.0",

"mz": "2.7.0",
"node-fetch": "2.3.0",
"rimraf": "2.6.3",
"rimraf-then": "1.0.1",
"tape": "4.10.1",
"ts-node": "7.0.1",
"ts-node": "8.0.3",
"tslint": "5.13.1",

@@ -66,8 +68,7 @@ "typescript": "3.3.3333"

"dependencies": {
"@pnpm/store-controller-types": "3.0.0-0",
"@pnpm/types": "2.0.0",
"@types/got": "8.3.4",
"@pnpm/fetch": "1.0.0",
"@pnpm/store-controller-types": "3.0.0",
"@pnpm/types": "3.0.0",
"@types/node": "11.9.5",
"@types/uuid": "3.4.4",
"got": "8.3.2",
"p-limit": "2.2.0",

@@ -74,0 +75,0 @@ "uuid": "3.3.2"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc