Socket
Socket
Sign inDemoInstall

query-registry

Package Overview
Dependencies
44
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.0 to 2.3.0-0

dist/query-registry.esm.js

8

dist/query-registry.cjs.development.js

@@ -9,2 +9,3 @@ 'use strict';

var lru = require('tiny-lru');
var urlJoin = require('url-join');
var gitUrlParse = require('git-url-parse');

@@ -36,2 +37,3 @@

var lru__default = /*#__PURE__*/_interopDefaultLegacy(lru);
var urlJoin__default = /*#__PURE__*/_interopDefaultLegacy(urlJoin);
var gitUrlParse__default = /*#__PURE__*/_interopDefaultLegacy(gitUrlParse);

@@ -217,7 +219,3 @@

}) {
const urls = [registry, ...mirrors].map(host => {
const url = new URL(endpoint, host);
url.search = query != null ? query : '';
return url.href;
});
const urls = [registry, ...mirrors].map(base => urlJoin__default["default"](base, endpoint, query ? `?${query}` : ''));
let lastError;

@@ -224,0 +222,0 @@

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("validate-npm-package-name"),e=require("make-error"),t=require("isomorphic-unfetch"),n=require("tiny-lru"),a=require("git-url-parse");function i(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var s=i(r),o=i(e),c=i(t),d=i(n),u=i(a);const p=["https://registry.npmjs.cf","https://registry.yarnpkg.com"];class y extends e.BaseError{constructor(r,e){super(`fetch: request to ${r} failed with status ${e.statusText}`),this.url=void 0,this.response=void 0,this.url=r,this.response=e}}const g=o.default("InvalidPackageNameError"),l=o.default("InvalidPackageVersionError");async function m(r,...e){}function f({name:r}){const{validForOldPackages:e,validForNewPackages:t}=s.default(r);if(!e&&!t)throw m(),new g(`invalid package name: '${r}'`)}const h=d.default(250,3e5);async function w({url:r,headers:e,cached:t=!0}){const n=`headers=${JSON.stringify(e)};url=${r}`,a=h.get(n);if(t&&a)return m(),a;const i=await c.default(r,{headers:e});if(!i.ok)throw m(),new y(r,i);const s=await i.json();return t&&h.set(n,s),m(),s}async function P({endpoint:r,headers:e,query:t,registry:n="https://registry.npmjs.org",mirrors:a=p,cached:i}){const s=[n,...a].map((e=>{const n=new URL(r,e);return n.search=null!=t?t:"",n.href}));let o;for(const r of s)try{return await w({url:r,headers:e,cached:i})}catch(r){o=r}throw m(),o}async function k({name:r,registry:e,mirrors:t,cached:n}){return f({name:r}),P({endpoint:`/${r}`,headers:{Accept:"application/vnd.npm.install-v1+json"},registry:e,mirrors:t,cached:n})}async function v({endpoint:r,registryDownloadsAPI:e="https://api.npmjs.org",cached:t}){return P({endpoint:r,registry:e,mirrors:[],cached:t})}function $({rawDownloadPeriod:r="last-week"}){if("string"==typeof r)return r;if(r instanceof Date)return b(r);const{start:e,end:t}=r;return`${b(e)}:${b(t)}`}function b(r){return r.toISOString().split("T")[0]}function x({rawPackument:r,version:e="latest"}){var t;const{name:n,"dist-tags":a,versions:i}=r,s=i[null!=(t=a[e])?t:e];if(!s)throw m(),new l(`invalid package version: '${n}@${e}'`);return s}async function D({name:r,registry:e,mirrors:t,cached:n}){return f({name:r}),P({endpoint:`/${r}`,registry:e,mirrors:t,cached:n})}async function R({name:r,version:e,registry:t,mirrors:n,cached:a}){return x({rawPackument:await D({name:r,registry:t,mirrors:n,cached:a}),version:e})}function A({rawLicense:r}){if(r&&"string"==typeof r)return r}function j({rawRepository:r}){return function(r){return r&&"object"==typeof r&&"string"==typeof r.url&&["string","undefined"].includes(typeof r.type)&&["string","undefined"].includes(typeof r.directory)}(r)?I({rawRepository:r}):"string"==typeof r?I({rawRepository:{url:r}}):void 0}function I({rawRepository:r}){const{url:e,directory:t}=r,n=function({url:r}){let e;try{e=u.default(r)}catch{}return e}({url:e});if(!n)return;const{source:a,full_name:i,filepath:s}=n;return{type:"git",url:`https://${a.replace(/^$/,"github.com").replace(/^github$/,"github.com").replace(/^gitlab$/,"gitlab.com").replace(/^bitbucket$/,"bitbucket.org")}/${i}`,directory:null!=t?t:""!==s?s:void 0}}exports.FetchError=y,exports.InvalidPackageNameError=g,exports.InvalidPackageVersionError=l,exports.cloudflareRegistry="https://registry.npmjs.cf",exports.getAbbreviatedPackument=async function({name:r,registry:e,mirrors:t,cached:n}){return function({rawAbbreviatedPackument:r}){const{"dist-tags":e,name:t,modified:n}=r;return{...r,id:t,distTags:e,modifiedAt:n}}({rawAbbreviatedPackument:await k({name:r,registry:e,mirrors:t,cached:n})})},exports.getDailyPackageDownloads=async function({name:r,period:e,registryDownloadsAPI:t,cached:n}){return f({name:r}),v({endpoint:`/downloads/range/${$({rawDownloadPeriod:e})}/${r}`,registryDownloadsAPI:t,cached:n})},exports.getDailyRegistryDownloads=async function({period:r,registryDownloadsAPI:e,cached:t}={}){return v({endpoint:`/downloads/range/${$({rawDownloadPeriod:r})}`,registryDownloadsAPI:e,cached:t})},exports.getPackageDownloads=async function({name:r,period:e,registryDownloadsAPI:t,cached:n}){return f({name:r}),v({endpoint:`/downloads/point/${$({rawDownloadPeriod:e})}/${r}`,registryDownloadsAPI:t,cached:n})},exports.getPackageManifest=async function({name:r,version:e,registry:t,mirrors:n,cached:a}){const i=await D({name:r,registry:t,mirrors:n,cached:a}),s=x({rawPackument:i,version:e});return await async function({rawPackageManifest:r,rawPackument:e,registry:t,mirrors:n,cached:a}){const{_id:i,name:s,version:o,license:c,repository:d,_npmUser:u}=r,p=e.time[o],y=A({rawLicense:c}),g=j({rawRepository:d}),l=await async function({rawPackageManifest:r,registry:e,mirrors:t,cached:n}){const{name:a,types:i,typings:s}=r,o=function({name:r}){return r.startsWith("@types/")?r:`@types/${r.replace("@","").replace("/","__")}`}({name:a});if(a===o||i||s)return;let c=!1;try{const{deprecated:r}=await R({name:o,registry:e,mirrors:t,cached:n});c=void 0===r}catch{}return c?o:void 0}({rawPackageManifest:r,registry:t,mirrors:n,cached:a}),m=function({name:r}){if(!r.startsWith("@types/"))return;const[e,t]=r.replace("@types/","").split("__");return t?`@${e}/${t}`:e}({name:s});return{...r,id:i,createdAt:p,publisher:u,license:y,gitRepository:g,definitelyTypedName:l,untypedName:m}}({rawPackageManifest:s,rawPackument:i,registry:t,mirrors:n,cached:a})},exports.getPackument=async function({name:r,registry:e,mirrors:t,cached:n}){return function({rawPackument:r}){const{_id:e,"dist-tags":t,time:n,license:a,repository:i}=r,s=A({rawLicense:a}),o=j({rawRepository:i}),c=Object.fromEntries(Object.entries(n).filter((([r])=>!["created","modified"].includes(r))));return{...r,id:e,distTags:t,versionsToTimestamps:c,license:s,gitRepository:o}}({rawPackument:await D({name:r,registry:e,mirrors:t,cached:n})})},exports.getRawAbbreviatedPackument=k,exports.getRawPackageManifest=R,exports.getRawPackument=D,exports.getRegistryDownloads=async function({period:r,registryDownloadsAPI:e,cached:t}={}){return v({endpoint:`/downloads/point/${$({rawDownloadPeriod:r})}`,registryDownloadsAPI:e,cached:t})},exports.getRegistryMetadata=async function({registry:r,cached:e}={}){return P({registry:r,mirrors:[],endpoint:"/",cached:e})},exports.npmRegistry="https://registry.npmjs.org",exports.npmRegistryDownloadsAPI="https://api.npmjs.org",exports.npmRegistryMirrors=p,exports.searchPackages=async function({query:r,registry:e,mirrors:t,cached:n}){const a=function({rawSearchCriteria:r}){return Object.entries(r).filter((([,r])=>["string","number"].includes(typeof r))).map((([r,e])=>`${r}=${e}`)).join("&")}({rawSearchCriteria:r});return P({endpoint:"/-/v1/search",query:a,registry:e,mirrors:t,cached:n})},exports.yarnRegistry="https://registry.yarnpkg.com";
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("validate-npm-package-name"),e=require("make-error"),t=require("isomorphic-unfetch"),n=require("tiny-lru"),a=require("url-join"),i=require("git-url-parse");function s(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var o=s(r),c=s(e),d=s(t),u=s(n),p=s(a),y=s(i);const g=["https://registry.npmjs.cf","https://registry.yarnpkg.com"];class l extends e.BaseError{constructor(r,e){super(`fetch: request to ${r} failed with status ${e.statusText}`),this.url=void 0,this.response=void 0,this.url=r,this.response=e}}const m=c.default("InvalidPackageNameError"),f=c.default("InvalidPackageVersionError");async function h(r,...e){}function w({name:r}){const{validForOldPackages:e,validForNewPackages:t}=o.default(r);if(!e&&!t)throw h(),new m(`invalid package name: '${r}'`)}const P=u.default(250,3e5);async function k({url:r,headers:e,cached:t=!0}){const n=`headers=${JSON.stringify(e)};url=${r}`,a=P.get(n);if(t&&a)return h(),a;const i=await d.default(r,{headers:e});if(!i.ok)throw h(),new l(r,i);const s=await i.json();return t&&P.set(n,s),h(),s}async function v({endpoint:r,headers:e,query:t,registry:n="https://registry.npmjs.org",mirrors:a=g,cached:i}){const s=[n,...a].map((e=>p.default(e,r,t?`?${t}`:"")));let o;for(const r of s)try{return await k({url:r,headers:e,cached:i})}catch(r){o=r}throw h(),o}async function $({name:r,registry:e,mirrors:t,cached:n}){return w({name:r}),v({endpoint:`/${r}`,headers:{Accept:"application/vnd.npm.install-v1+json"},registry:e,mirrors:t,cached:n})}async function b({endpoint:r,registryDownloadsAPI:e="https://api.npmjs.org",cached:t}){return v({endpoint:r,registry:e,mirrors:[],cached:t})}function x({rawDownloadPeriod:r="last-week"}){if("string"==typeof r)return r;if(r instanceof Date)return D(r);const{start:e,end:t}=r;return`${D(e)}:${D(t)}`}function D(r){return r.toISOString().split("T")[0]}function R({rawPackument:r,version:e="latest"}){var t;const{name:n,"dist-tags":a,versions:i}=r,s=i[null!=(t=a[e])?t:e];if(!s)throw h(),new f(`invalid package version: '${n}@${e}'`);return s}async function A({name:r,registry:e,mirrors:t,cached:n}){return w({name:r}),v({endpoint:`/${r}`,registry:e,mirrors:t,cached:n})}async function j({name:r,version:e,registry:t,mirrors:n,cached:a}){return R({rawPackument:await A({name:r,registry:t,mirrors:n,cached:a}),version:e})}function I({rawLicense:r}){if(r&&"string"==typeof r)return r}function q({rawRepository:r}){return function(r){return r&&"object"==typeof r&&"string"==typeof r.url&&["string","undefined"].includes(typeof r.type)&&["string","undefined"].includes(typeof r.directory)}(r)?_({rawRepository:r}):"string"==typeof r?_({rawRepository:{url:r}}):void 0}function _({rawRepository:r}){const{url:e,directory:t}=r,n=function({url:r}){let e;try{e=y.default(r)}catch{}return e}({url:e});if(!n)return;const{source:a,full_name:i,filepath:s}=n;return{type:"git",url:`https://${a.replace(/^$/,"github.com").replace(/^github$/,"github.com").replace(/^gitlab$/,"gitlab.com").replace(/^bitbucket$/,"bitbucket.org")}/${i}`,directory:null!=t?t:""!==s?s:void 0}}exports.FetchError=l,exports.InvalidPackageNameError=m,exports.InvalidPackageVersionError=f,exports.cloudflareRegistry="https://registry.npmjs.cf",exports.getAbbreviatedPackument=async function({name:r,registry:e,mirrors:t,cached:n}){return function({rawAbbreviatedPackument:r}){const{"dist-tags":e,name:t,modified:n}=r;return{...r,id:t,distTags:e,modifiedAt:n}}({rawAbbreviatedPackument:await $({name:r,registry:e,mirrors:t,cached:n})})},exports.getDailyPackageDownloads=async function({name:r,period:e,registryDownloadsAPI:t,cached:n}){return w({name:r}),b({endpoint:`/downloads/range/${x({rawDownloadPeriod:e})}/${r}`,registryDownloadsAPI:t,cached:n})},exports.getDailyRegistryDownloads=async function({period:r,registryDownloadsAPI:e,cached:t}={}){return b({endpoint:`/downloads/range/${x({rawDownloadPeriod:r})}`,registryDownloadsAPI:e,cached:t})},exports.getPackageDownloads=async function({name:r,period:e,registryDownloadsAPI:t,cached:n}){return w({name:r}),b({endpoint:`/downloads/point/${x({rawDownloadPeriod:e})}/${r}`,registryDownloadsAPI:t,cached:n})},exports.getPackageManifest=async function({name:r,version:e,registry:t,mirrors:n,cached:a}){const i=await A({name:r,registry:t,mirrors:n,cached:a}),s=R({rawPackument:i,version:e});return await async function({rawPackageManifest:r,rawPackument:e,registry:t,mirrors:n,cached:a}){const{_id:i,name:s,version:o,license:c,repository:d,_npmUser:u}=r,p=e.time[o],y=I({rawLicense:c}),g=q({rawRepository:d}),l=await async function({rawPackageManifest:r,registry:e,mirrors:t,cached:n}){const{name:a,types:i,typings:s}=r,o=function({name:r}){return r.startsWith("@types/")?r:`@types/${r.replace("@","").replace("/","__")}`}({name:a});if(a===o||i||s)return;let c=!1;try{const{deprecated:r}=await j({name:o,registry:e,mirrors:t,cached:n});c=void 0===r}catch{}return c?o:void 0}({rawPackageManifest:r,registry:t,mirrors:n,cached:a}),m=function({name:r}){if(!r.startsWith("@types/"))return;const[e,t]=r.replace("@types/","").split("__");return t?`@${e}/${t}`:e}({name:s});return{...r,id:i,createdAt:p,publisher:u,license:y,gitRepository:g,definitelyTypedName:l,untypedName:m}}({rawPackageManifest:s,rawPackument:i,registry:t,mirrors:n,cached:a})},exports.getPackument=async function({name:r,registry:e,mirrors:t,cached:n}){return function({rawPackument:r}){const{_id:e,"dist-tags":t,time:n,license:a,repository:i}=r,s=I({rawLicense:a}),o=q({rawRepository:i}),c=Object.fromEntries(Object.entries(n).filter((([r])=>!["created","modified"].includes(r))));return{...r,id:e,distTags:t,versionsToTimestamps:c,license:s,gitRepository:o}}({rawPackument:await A({name:r,registry:e,mirrors:t,cached:n})})},exports.getRawAbbreviatedPackument=$,exports.getRawPackageManifest=j,exports.getRawPackument=A,exports.getRegistryDownloads=async function({period:r,registryDownloadsAPI:e,cached:t}={}){return b({endpoint:`/downloads/point/${x({rawDownloadPeriod:r})}`,registryDownloadsAPI:e,cached:t})},exports.getRegistryMetadata=async function({registry:r,cached:e}={}){return v({registry:r,mirrors:[],endpoint:"/",cached:e})},exports.npmRegistry="https://registry.npmjs.org",exports.npmRegistryDownloadsAPI="https://api.npmjs.org",exports.npmRegistryMirrors=g,exports.searchPackages=async function({query:r,registry:e,mirrors:t,cached:n}){const a=function({rawSearchCriteria:r}){return Object.entries(r).filter((([,r])=>["string","number"].includes(typeof r))).map((([r,e])=>`${r}=${e}`)).join("&")}({rawSearchCriteria:r});return v({endpoint:"/-/v1/search",query:a,registry:e,mirrors:t,cached:n})},exports.yarnRegistry="https://registry.yarnpkg.com";
//# sourceMappingURL=query-registry.cjs.production.min.js.map
import { npmRegistry, npmRegistryMirrors } from '../data/registries.esm.js';
import { fetch } from './fetch.esm.js';
import { log } from './log.esm.js';
import urlJoin from 'url-join';

@@ -13,7 +14,3 @@ async function fetchFromRegistry({

}) {
const urls = [registry, ...mirrors].map(host => {
const url = new URL(endpoint, host);
url.search = query != null ? query : '';
return url.href;
});
const urls = [registry, ...mirrors].map(base => urlJoin(base, endpoint, query ? `?${query}` : ''));
let lastError;

@@ -20,0 +17,0 @@

{
"name": "query-registry",
"description": "Query the npm registry for packuments, manifests, packages and download counts",
"version": "2.2.0",
"version": "2.3.0-0",
"author": "Edoardo Scibona (velut)",

@@ -65,11 +65,12 @@ "license": "MIT",

"make-error": "^1.3.6",
"tiny-lru": "^7.0.6",
"validate-npm-package-name": "^3.0.0"
"tiny-lru": "^8.0.1",
"url-join": "4.0.1",
"validate-npm-package-name": "^4.0.0"
},
"devDependencies": {
"@commitlint/cli": "15.0.0",
"@commitlint/config-conventional": "15.0.0",
"@pollyjs/adapter-node-http": "6.0.0",
"@pollyjs/core": "6.0.0",
"@pollyjs/persister-fs": "6.0.0",
"@commitlint/cli": "16.2.3",
"@commitlint/config-conventional": "16.2.1",
"@pollyjs/adapter-node-http": "6.0.5",
"@pollyjs/core": "6.0.5",
"@pollyjs/persister-fs": "6.0.5",
"@types/debug": "4.1.7",

@@ -81,14 +82,15 @@ "@types/git-url-parse": "9.0.1",

"@types/setup-polly-jest": "0.5.1",
"@types/url-join": "4.0.1",
"@types/validate-npm-package-name": "3.0.3",
"debug": "4.3.3",
"dts-cli": "0.20.0",
"debug": "4.3.4",
"dts-cli": "1.5.1",
"eslint-plugin-prettier": "4.0.0",
"husky": "7.0.4",
"nock": "13.2.1",
"np": "7.6.0",
"prettier": "2.5.0",
"nock": "13.2.4",
"np": "7.6.1",
"prettier": "2.6.2",
"setup-polly-jest": "0.10.0",
"tslib": "2.3.1",
"typescript": "4.5.2"
"tslib": "2.4.0",
"typescript": "4.6.3"
}
}

@@ -5,2 +5,3 @@ import { npmRegistry, npmRegistryMirrors } from '../data/registries';

import { log } from './log';
import urlJoin from 'url-join';

@@ -22,7 +23,5 @@ export async function fetchFromRegistry<T>({

}): Promise<T> {
const urls = [registry, ...mirrors].map((host) => {
const url = new URL(endpoint, host);
url.search = query ?? '';
return url.href;
});
const urls = [registry, ...mirrors].map((base) =>
urlJoin(base, endpoint, query ? `?${query}` : '')
);

@@ -29,0 +28,0 @@ let lastError: FetchError | undefined;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc