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.3.0 to 2.4.0

30

CHANGELOG.md

@@ -12,2 +12,17 @@ # Changelog

## [2.3.0] - 2022-04-27
### Added
- N/A
### Changed
- Preserve pathnames in registry URLs (`https://example.com/my/npm/registry`)
- Updated dependencies and dev dependencies
### Removed
- N/A
## [2.2.0] - 2021-12-01

@@ -17,14 +32,14 @@

- [Abbreviated packuments](https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-metadata-format) (`application/vnd.npm.install-v1+json`) can now be retrieved using `getAbbreviatedPackument()` or `getRawAbbreviatedPackument()`
- [Abbreviated packuments](https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-metadata-format) (`application/vnd.npm.install-v1+json`) can now be retrieved using `getAbbreviatedPackument()` or `getRawAbbreviatedPackument()`
### Changed
- Responses are now cached based on headers and URL
- Updated docs
- Updated dependencies and dev dependencies
- Moved `debug` package to dev dependencies
- Responses are now cached based on headers and URL
- Updated docs
- Updated dependencies and dev dependencies
- Moved `debug` package to dev dependencies
### Removed
- N/A
- N/A

@@ -59,4 +74,5 @@ ## [2.0.0] - 2021-03-09

[unreleased]: https://github.com/velut/node-query-registry/compare/v2.2.0...HEAD
[unreleased]: https://github.com/velut/node-query-registry/compare/v2.3.0...HEAD
[2.0.0]: https://github.com/velut/node-query-registry/compare/v1.2.0...v2.0.0
[2.2.0]: https://github.com/velut/node-query-registry/compare/v2.0.0...v2.2.0
[2.3.0]: https://github.com/velut/node-query-registry/compare/v2.2.0...v2.3.0

@@ -836,3 +836,3 @@ 'use strict';

const {
source,
resource,
full_name: repositoryID,

@@ -842,3 +842,3 @@ filepath

const host = source.replace(/^$/, 'github.com').replace(/^github$/, 'github.com').replace(/^gitlab$/, 'gitlab.com').replace(/^bitbucket$/, 'bitbucket.org');
const host = resource.replace(/^$/, 'github.com').replace(/^github$/, 'github.com').replace(/^gitlab$/, 'gitlab.com').replace(/^bitbucket$/, 'bitbucket.org');
const parsedDir = filepath !== '' ? filepath : undefined;

@@ -845,0 +845,0 @@ return {

@@ -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("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";
"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{resource: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

@@ -43,3 +43,3 @@ import gitUrlParse from 'git-url-parse';

const {
source,
resource,
full_name: repositoryID,

@@ -49,3 +49,3 @@ filepath

const host = source.replace(/^$/, 'github.com').replace(/^github$/, 'github.com').replace(/^gitlab$/, 'gitlab.com').replace(/^bitbucket$/, 'bitbucket.org');
const host = resource.replace(/^$/, 'github.com').replace(/^github$/, 'github.com').replace(/^gitlab$/, 'gitlab.com').replace(/^bitbucket$/, 'bitbucket.org');
const parsedDir = filepath !== '' ? filepath : undefined;

@@ -52,0 +52,0 @@ return {

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

@@ -70,4 +70,4 @@ "license": "MIT",

"devDependencies": {
"@commitlint/cli": "16.2.3",
"@commitlint/config-conventional": "16.2.1",
"@commitlint/cli": "16.2.4",
"@commitlint/config-conventional": "16.2.4",
"@pollyjs/adapter-node-http": "6.0.5",

@@ -93,4 +93,4 @@ "@pollyjs/core": "6.0.5",

"tslib": "2.4.0",
"typescript": "4.6.3"
"typescript": "4.6.4"
}
}

@@ -45,6 +45,6 @@ import gitUrlParse from 'git-url-parse';

const { source, full_name: repositoryID, filepath } = info;
const { resource, full_name: repositoryID, filepath } = info;
// Add domain to sources derived from npm-style shortcuts
const host = source
const host = resource
.replace(/^$/, 'github.com')

@@ -51,0 +51,0 @@ .replace(/^github$/, 'github.com')

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