0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-04-08 02:54:13 -05:00

refactor: migrate @verdaccio/types@11.x ()

* refactor: migrate @verdaccio/types@11

* deps
This commit is contained in:
Juan Picado 2023-03-18 22:40:34 +01:00 committed by GitHub
parent b85ba995b5
commit 783422b4a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 394 additions and 645 deletions

154
.pnp.cjs generated
View file

@ -69,17 +69,17 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@typescript-eslint/parser", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.49.0"],\
["@verdaccio-scope/verdaccio-auth-foo", "npm:0.0.2"],\
["@verdaccio/config", "npm:6.0.0-6-next.66"],\
["@verdaccio/core", "npm:6.0.0-6-next.66"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\
["@verdaccio/local-storage", "npm:10.3.1"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.11"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.45"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.12"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.46"],\
["@verdaccio/signature", "npm:6.0.0-6-next.2"],\
["@verdaccio/streams", "npm:10.2.0"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.35"],\
["@verdaccio/types", "npm:10.7.1"],\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.66"],\
["@verdaccio/url", "npm:11.0.0-6-next.32"],\
["@verdaccio/utils", "npm:6.0.0-6-next.34"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.36"],\
["@verdaccio/types", "npm:11.0.0-6-next.25"],\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.67"],\
["@verdaccio/url", "npm:11.0.0-6-next.33"],\
["@verdaccio/utils", "npm:6.0.0-6-next.35"],\
["JSONStream", "npm:1.3.5"],\
["async", "npm:3.2.4"],\
["babel-eslint", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.1.0"],\
@ -137,7 +137,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["ts-node", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.9.1"],\
["typescript", "patch:typescript@npm%3A4.9.5#~builtin<compat/typescript>::version=4.9.5&hash=ad5954"],\
["validator", "npm:13.9.0"],\
["verdaccio-audit", "npm:11.0.0-6-next.29"],\
["verdaccio-audit", "npm:11.0.0-6-next.30"],\
["verdaccio-auth-memory", "npm:10.2.0"],\
["verdaccio-htpasswd", "npm:10.5.2"],\
["verdaccio-memory", "npm:10.3.0"]\
@ -5033,6 +5033,20 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["yup", "npm:0.32.11"]\
],\
"linkType": "HARD"\
}],\
["npm:6.0.0-6-next.67", {\
"packageLocation": "./.yarn/cache/@verdaccio-config-npm-6.0.0-6-next.67-6558a1c7e5-822fd5d63d.zip/node_modules/@verdaccio/config/",\
"packageDependencies": [\
["@verdaccio/config", "npm:6.0.0-6-next.67"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\
["@verdaccio/utils", "npm:6.0.0-6-next.35"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["js-yaml", "npm:4.1.0"],\
["lodash", "npm:4.17.21"],\
["minimatch", "npm:3.1.2"],\
["yup", "npm:0.32.11"]\
],\
"linkType": "HARD"\
}]\
]],\
["@verdaccio/core", [\
@ -5048,6 +5062,19 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["semver", "npm:7.3.8"]\
],\
"linkType": "HARD"\
}],\
["npm:6.0.0-6-next.67", {\
"packageLocation": "./.yarn/cache/@verdaccio-core-npm-6.0.0-6-next.67-982000a47a-c039318870.zip/node_modules/@verdaccio/core/",\
"packageDependencies": [\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\
["ajv", "npm:8.11.2"],\
["core-js", "npm:3.28.0"],\
["http-errors", "npm:1.8.1"],\
["http-status-codes", "npm:2.2.0"],\
["process-warning", "npm:1.0.0"],\
["semver", "npm:7.3.8"]\
],\
"linkType": "HARD"\
}]\
]],\
["@verdaccio/file-locking", [\
@ -5078,22 +5105,22 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/logger-7", [\
["npm:6.0.0-6-next.11", {\
"packageLocation": "./.yarn/cache/@verdaccio-logger-7-npm-6.0.0-6-next.11-32fa0eade0-755f7f3a61.zip/node_modules/@verdaccio/logger-7/",\
["npm:6.0.0-6-next.12", {\
"packageLocation": "./.yarn/cache/@verdaccio-logger-7-npm-6.0.0-6-next.12-1a78df2245-3585b19083.zip/node_modules/@verdaccio/logger-7/",\
"packageDependencies": [\
["@verdaccio/logger-7", "npm:6.0.0-6-next.11"],\
["@verdaccio/logger-commons", "npm:6.0.0-6-next.34"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.12"],\
["@verdaccio/logger-commons", "npm:6.0.0-6-next.35"],\
["pino", "npm:7.11.0"]\
],\
"linkType": "HARD"\
}]\
]],\
["@verdaccio/logger-commons", [\
["npm:6.0.0-6-next.34", {\
"packageLocation": "./.yarn/cache/@verdaccio-logger-commons-npm-6.0.0-6-next.34-12502b6e05-6bcb5fa99b.zip/node_modules/@verdaccio/logger-commons/",\
["npm:6.0.0-6-next.35", {\
"packageLocation": "./.yarn/cache/@verdaccio-logger-commons-npm-6.0.0-6-next.35-a2c2cd0eaf-1726111f2b.zip/node_modules/@verdaccio/logger-commons/",\
"packageDependencies": [\
["@verdaccio/logger-commons", "npm:6.0.0-6-next.34"],\
["@verdaccio/core", "npm:6.0.0-6-next.66"],\
["@verdaccio/logger-commons", "npm:6.0.0-6-next.35"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\
["@verdaccio/logger-prettify", "npm:6.0.0-6-next.9"],\
["colorette", "npm:2.0.19"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"]\
@ -5116,14 +5143,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/middleware", [\
["npm:6.0.0-6-next.45", {\
"packageLocation": "./.yarn/cache/@verdaccio-middleware-npm-6.0.0-6-next.45-e32a5e7bea-d3be4aae54.zip/node_modules/@verdaccio/middleware/",\
["npm:6.0.0-6-next.46", {\
"packageLocation": "./.yarn/cache/@verdaccio-middleware-npm-6.0.0-6-next.46-18be481d80-a53154f3b5.zip/node_modules/@verdaccio/middleware/",\
"packageDependencies": [\
["@verdaccio/middleware", "npm:6.0.0-6-next.45"],\
["@verdaccio/config", "npm:6.0.0-6-next.66"],\
["@verdaccio/core", "npm:6.0.0-6-next.66"],\
["@verdaccio/url", "npm:11.0.0-6-next.32"],\
["@verdaccio/utils", "npm:6.0.0-6-next.34"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.46"],\
["@verdaccio/config", "npm:6.0.0-6-next.67"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\
["@verdaccio/url", "npm:11.0.0-6-next.33"],\
["@verdaccio/utils", "npm:6.0.0-6-next.35"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["express", "npm:4.18.2"],\
["express-rate-limit", "npm:5.5.1"],\
@ -5156,13 +5183,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/tarball", [\
["npm:11.0.0-6-next.35", {\
"packageLocation": "./.yarn/cache/@verdaccio-tarball-npm-11.0.0-6-next.35-7517c8d3ff-6ab29b067c.zip/node_modules/@verdaccio/tarball/",\
["npm:11.0.0-6-next.36", {\
"packageLocation": "./.yarn/cache/@verdaccio-tarball-npm-11.0.0-6-next.36-06d2d9ff39-857d74fbb1.zip/node_modules/@verdaccio/tarball/",\
"packageDependencies": [\
["@verdaccio/tarball", "npm:11.0.0-6-next.35"],\
["@verdaccio/core", "npm:6.0.0-6-next.66"],\
["@verdaccio/url", "npm:11.0.0-6-next.32"],\
["@verdaccio/utils", "npm:6.0.0-6-next.34"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.36"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\
["@verdaccio/url", "npm:11.0.0-6-next.33"],\
["@verdaccio/utils", "npm:6.0.0-6-next.35"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["lodash", "npm:4.17.21"]\
],\
@ -5170,29 +5197,29 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/types", [\
["npm:10.7.1", {\
"packageLocation": "./.yarn/cache/@verdaccio-types-npm-10.7.1-3c42d169da-086ef79ef1.zip/node_modules/@verdaccio/types/",\
["npm:11.0.0-6-next.25", {\
"packageLocation": "./.yarn/cache/@verdaccio-types-npm-11.0.0-6-next.25-0d2e43d5d7-5e5628b270.zip/node_modules/@verdaccio/types/",\
"packageDependencies": [\
["@verdaccio/types", "npm:10.7.1"]\
["@verdaccio/types", "npm:11.0.0-6-next.25"]\
],\
"linkType": "HARD"\
}]\
]],\
["@verdaccio/ui-theme", [\
["npm:6.0.0-6-next.66", {\
"packageLocation": "./.yarn/cache/@verdaccio-ui-theme-npm-6.0.0-6-next.66-fc1c12b39e-d255ef2e19.zip/node_modules/@verdaccio/ui-theme/",\
["npm:6.0.0-6-next.67", {\
"packageLocation": "./.yarn/cache/@verdaccio-ui-theme-npm-6.0.0-6-next.67-b1aee354b9-5e6a8deca7.zip/node_modules/@verdaccio/ui-theme/",\
"packageDependencies": [\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.66"]\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.67"]\
],\
"linkType": "HARD"\
}]\
]],\
["@verdaccio/url", [\
["npm:11.0.0-6-next.32", {\
"packageLocation": "./.yarn/cache/@verdaccio-url-npm-11.0.0-6-next.32-3acb323e43-93ac44ed59.zip/node_modules/@verdaccio/url/",\
["npm:11.0.0-6-next.33", {\
"packageLocation": "./.yarn/cache/@verdaccio-url-npm-11.0.0-6-next.33-64ed74304b-e138638e0f.zip/node_modules/@verdaccio/url/",\
"packageDependencies": [\
["@verdaccio/url", "npm:11.0.0-6-next.32"],\
["@verdaccio/core", "npm:6.0.0-6-next.66"],\
["@verdaccio/url", "npm:11.0.0-6-next.33"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["lodash", "npm:4.17.21"],\
["validator", "npm:13.9.0"]\
@ -5211,6 +5238,17 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["semver", "npm:7.3.8"]\
],\
"linkType": "HARD"\
}],\
["npm:6.0.0-6-next.35", {\
"packageLocation": "./.yarn/cache/@verdaccio-utils-npm-6.0.0-6-next.35-5c76e3b578-97f04effaf.zip/node_modules/@verdaccio/utils/",\
"packageDependencies": [\
["@verdaccio/utils", "npm:6.0.0-6-next.35"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\
["lodash", "npm:4.17.21"],\
["minimatch", "npm:3.1.2"],\
["semver", "npm:7.3.8"]\
],\
"linkType": "HARD"\
}]\
]],\
["@yarnpkg/parsers", [\
@ -11276,10 +11314,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
],\
"linkType": "HARD"\
}],\
["virtual:6e1bae984e0421880dec200b1132ee3710834aa34f7388c9d6fb1fe3096e6c80f480bc4a013efdb3ac626a6cd42b233561ca750b2eb75353314da0b36aa71258#npm:2.6.7", {\
"packageLocation": "./.yarn/__virtual__/node-fetch-virtual-b76f6b8cb5/0/cache/node-fetch-npm-2.6.7-777aa2a6df-8d816ffd1e.zip/node_modules/node-fetch/",\
["virtual:2c0413d013d95d792b4734fb5ba2b862c449db8f59693f269cdf9e3bf579fb5c5441b1fba98d8e06ba2937e2a5a71c997d9ebf245147018bc6b0d9897ab45083#npm:2.6.7", {\
"packageLocation": "./.yarn/__virtual__/node-fetch-virtual-c70b7cc8e9/0/cache/node-fetch-npm-2.6.7-777aa2a6df-8d816ffd1e.zip/node_modules/node-fetch/",\
"packageDependencies": [\
["node-fetch", "virtual:6e1bae984e0421880dec200b1132ee3710834aa34f7388c9d6fb1fe3096e6c80f480bc4a013efdb3ac626a6cd42b233561ca750b2eb75353314da0b36aa71258#npm:2.6.7"],\
["node-fetch", "virtual:2c0413d013d95d792b4734fb5ba2b862c449db8f59693f269cdf9e3bf579fb5c5441b1fba98d8e06ba2937e2a5a71c997d9ebf245147018bc6b0d9897ab45083#npm:2.6.7"],\
["@types/encoding", null],\
["encoding", null],\
["whatwg-url", "npm:5.0.0"]\
@ -13948,17 +13986,17 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@typescript-eslint/parser", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.49.0"],\
["@verdaccio-scope/verdaccio-auth-foo", "npm:0.0.2"],\
["@verdaccio/config", "npm:6.0.0-6-next.66"],\
["@verdaccio/core", "npm:6.0.0-6-next.66"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\
["@verdaccio/local-storage", "npm:10.3.1"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.11"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.45"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.12"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.46"],\
["@verdaccio/signature", "npm:6.0.0-6-next.2"],\
["@verdaccio/streams", "npm:10.2.0"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.35"],\
["@verdaccio/types", "npm:10.7.1"],\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.66"],\
["@verdaccio/url", "npm:11.0.0-6-next.32"],\
["@verdaccio/utils", "npm:6.0.0-6-next.34"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.36"],\
["@verdaccio/types", "npm:11.0.0-6-next.25"],\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.67"],\
["@verdaccio/url", "npm:11.0.0-6-next.33"],\
["@verdaccio/utils", "npm:6.0.0-6-next.35"],\
["JSONStream", "npm:1.3.5"],\
["async", "npm:3.2.4"],\
["babel-eslint", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.1.0"],\
@ -14016,7 +14054,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["ts-node", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.9.1"],\
["typescript", "patch:typescript@npm%3A4.9.5#~builtin<compat/typescript>::version=4.9.5&hash=ad5954"],\
["validator", "npm:13.9.0"],\
["verdaccio-audit", "npm:11.0.0-6-next.29"],\
["verdaccio-audit", "npm:11.0.0-6-next.30"],\
["verdaccio-auth-memory", "npm:10.2.0"],\
["verdaccio-htpasswd", "npm:10.5.2"],\
["verdaccio-memory", "npm:10.3.0"]\
@ -14025,15 +14063,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["verdaccio-audit", [\
["npm:11.0.0-6-next.29", {\
"packageLocation": "./.yarn/cache/verdaccio-audit-npm-11.0.0-6-next.29-6e1bae984e-746f0e3e37.zip/node_modules/verdaccio-audit/",\
["npm:11.0.0-6-next.30", {\
"packageLocation": "./.yarn/cache/verdaccio-audit-npm-11.0.0-6-next.30-2c0413d013-3cfd734653.zip/node_modules/verdaccio-audit/",\
"packageDependencies": [\
["verdaccio-audit", "npm:11.0.0-6-next.29"],\
["@verdaccio/config", "npm:6.0.0-6-next.66"],\
["@verdaccio/core", "npm:6.0.0-6-next.66"],\
["verdaccio-audit", "npm:11.0.0-6-next.30"],\
["@verdaccio/config", "npm:6.0.0-6-next.67"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\
["express", "npm:4.18.2"],\
["https-proxy-agent", "npm:5.0.1"],\
["node-fetch", "virtual:6e1bae984e0421880dec200b1132ee3710834aa34f7388c9d6fb1fe3096e6c80f480bc4a013efdb3ac626a6cd42b233561ca750b2eb75353314da0b36aa71258#npm:2.6.7"]\
["node-fetch", "virtual:2c0413d013d95d792b4734fb5ba2b862c449db8f59693f269cdf9e3bf579fb5c5441b1fba98d8e06ba2937e2a5a71c997d9ebf245147018bc6b0d9897ab45083#npm:2.6.7"]\
],\
"linkType": "HARD"\
}]\

View file

@ -1,6 +1,6 @@
{
"name": "eslint",
"version": "8.32.0-sdk",
"version": "8.34.0-sdk",
"main": "./lib/api.js",
"type": "commonjs"
}

View file

@ -1,6 +1,6 @@
{
"name": "prettier",
"version": "2.8.3-sdk",
"version": "2.8.4-sdk",
"main": "./index.js",
"type": "commonjs"
}

View file

@ -1,6 +1,6 @@
{
"name": "typescript",
"version": "4.1.3-sdk",
"version": "4.9.5-sdk",
"main": "./lib/typescript.js",
"type": "commonjs"
}

View file

@ -20,16 +20,16 @@
},
"dependencies": {
"@verdaccio/config": "6.0.0-6-next.66",
"@verdaccio/core": "6.0.0-6-next.66",
"@verdaccio/core": "6.0.0-6-next.67",
"@verdaccio/local-storage": "10.3.1",
"@verdaccio/logger-7": "6.0.0-6-next.11",
"@verdaccio/middleware": "6.0.0-6-next.45",
"@verdaccio/logger-7": "6.0.0-6-next.12",
"@verdaccio/middleware": "6.0.0-6-next.46",
"@verdaccio/signature": "6.0.0-6-next.2",
"@verdaccio/streams": "10.2.0",
"@verdaccio/tarball": "11.0.0-6-next.35",
"@verdaccio/ui-theme": "6.0.0-6-next.66",
"@verdaccio/url": "11.0.0-6-next.32",
"@verdaccio/utils": "6.0.0-6-next.34",
"@verdaccio/tarball": "11.0.0-6-next.36",
"@verdaccio/ui-theme": "6.0.0-6-next.67",
"@verdaccio/url": "11.0.0-6-next.33",
"@verdaccio/utils": "6.0.0-6-next.35",
"JSONStream": "1.3.5",
"async": "3.2.4",
"body-parser": "1.20.2",
@ -56,7 +56,7 @@
"request": "2.88.2",
"semver": "7.3.8",
"validator": "13.9.0",
"verdaccio-audit": "11.0.0-6-next.29",
"verdaccio-audit": "11.0.0-6-next.30",
"verdaccio-htpasswd": "10.5.2"
},
"devDependencies": {
@ -100,7 +100,7 @@
"@typescript-eslint/eslint-plugin": "5.49.0",
"@typescript-eslint/parser": "5.49.0",
"@verdaccio-scope/verdaccio-auth-foo": "0.0.2",
"@verdaccio/types": "10.7.1",
"@verdaccio/types": "11.0.0-6-next.25",
"babel-eslint": "10.1.0",
"babel-jest": "29.4.1",
"babel-plugin-dynamic-import-node": "2.3.3",
@ -188,7 +188,7 @@
},
"packageManager": "yarn@3.3.1",
"dependenciesMeta": {
"@verdaccio/logger-7@6.0.0-6-next.7": {
"@verdaccio/types@11.0.0-6-next.24": {
"unplugged": true
}
}

View file

@ -5,17 +5,13 @@ import mime from 'mime';
import { allow, media } from '@verdaccio/middleware';
import { Package } from '@verdaccio/types';
import Auth from '../../../lib/auth';
import { API_MESSAGE, DIST_TAGS, HTTP_STATUS } from '../../../lib/constants';
import { logger } from '../../../lib/logger';
import {
$NextFunctionVer,
$RequestExtend,
$ResponseExtend,
IAuth,
IStorageHandler,
} from '../../../types';
import Storage from '../../../lib/storage';
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../../../types';
export default function (route: Router, auth: IAuth, storage: IStorageHandler): void {
export default function (route: Router, auth: Auth, storage: Storage): void {
const can = allow(auth, {
beforeAll: (params, message) => logger.trace(params, message),
afterAll: (params, message) => logger.trace(params, message),

View file

@ -5,16 +5,12 @@ import { allow } from '@verdaccio/middleware';
import { convertDistRemoteToLocalTarballUrls } from '@verdaccio/tarball';
import { Config, Package } from '@verdaccio/types';
import Auth from '../../../lib/auth';
import { API_ERROR, DIST_TAGS, HEADERS } from '../../../lib/constants';
import { logger } from '../../../lib/logger';
import Storage from '../../../lib/storage';
import { ErrorCode, getVersion } from '../../../lib/utils';
import {
$NextFunctionVer,
$RequestExtend,
$ResponseExtend,
IAuth,
IStorageHandler,
} from '../../../types';
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../../../types';
import { getByQualityPriorityValue } from '../../../utils/string';
const downloadStream = (
@ -66,12 +62,7 @@ const redirectOrDownloadStream = (
});
};
export default function (
route: Router,
auth: IAuth,
storage: IStorageHandler,
config: Config
): void {
export default function (route: Router, auth: Auth, storage: Storage, config: Config): void {
const can = allow(auth, {
beforeAll: (params, message) => logger.trace(params, message),
afterAll: (params, message) => logger.trace(params, message),

View file

@ -8,26 +8,22 @@ import { validatioUtils } from '@verdaccio/core';
import { allow, expectJson, media } from '@verdaccio/middleware';
import { Callback, Config, MergeTags, Package, Version } from '@verdaccio/types';
import Auth from '../../../lib/auth';
import { API_ERROR, API_MESSAGE, DIST_TAGS, HEADERS, HTTP_STATUS } from '../../../lib/constants';
import { logger } from '../../../lib/logger';
import { notify } from '../../../lib/notify';
import Storage from '../../../lib/storage';
import { isPublishablePackage } from '../../../lib/storage-utils';
import { ErrorCode, hasDiffOneKey, isObject, isRelatedToDeprecation } from '../../../lib/utils';
import {
$NextFunctionVer,
$RequestExtend,
$ResponseExtend,
IAuth,
IStorageHandler,
} from '../../../types';
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../../../types';
import star from './star';
const debug = buildDebug('verdaccio:publish');
export default function publish(
router: Router,
auth: IAuth,
storage: IStorageHandler,
auth: Auth,
storage: Storage,
config: Config
): void {
const can = allow(auth, {
@ -141,7 +137,7 @@ export default function publish(
/**
* Publish a package
*/
export function publishPackage(storage: IStorageHandler, config: Config, auth: IAuth): any {
export function publishPackage(storage: Storage, config: Config, auth: Auth): any {
const starApi = star(storage);
return function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
const packageName = req.params.package;
@ -302,7 +298,7 @@ export function publishPackage(storage: IStorageHandler, config: Config, auth: I
/**
* un-publish a package
*/
export function unPublishPackage(storage: IStorageHandler) {
export function unPublishPackage(storage: Storage) {
return function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
const packageName = req.params.package;
debug('unpublishing %o', packageName);
@ -319,7 +315,7 @@ export function unPublishPackage(storage: IStorageHandler) {
/**
* Delete tarball
*/
export function removeTarball(storage: IStorageHandler) {
export function removeTarball(storage: Storage) {
return function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
const packageName = req.params.package;
const { filename, revision } = req.params;
@ -337,7 +333,7 @@ export function removeTarball(storage: IStorageHandler) {
/**
* Adds a new version
*/
export function addVersion(storage: IStorageHandler) {
export function addVersion(storage: Storage) {
return function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
const { version, tag } = req.params;
const packageName = req.params.package;
@ -358,7 +354,7 @@ export function addVersion(storage: IStorageHandler) {
/**
* uploadPackageTarball
*/
export function uploadPackageTarball(storage: IStorageHandler) {
export function uploadPackageTarball(storage: Storage) {
return function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
const packageName = req.params.package;
const stream = storage.addTarball(packageName, req.params.filename);

View file

@ -5,11 +5,12 @@ import _ from 'lodash';
import { HTTP_STATUS, USERS } from '../../../lib/constants';
import { logger } from '../../../lib/logger';
import { $NextFunctionVer, $RequestExtend, IStorageHandler } from '../../../types';
import Storage from '../../../lib/storage';
import { $NextFunctionVer, $RequestExtend } from '../../../types';
const debug = buildDebug('verdaccio:star');
export default function (
storage: IStorageHandler
storage: Storage
): (req: $RequestExtend, res: Response, next: $NextFunctionVer) => void {
const validateInputs = (newUsers, localUsers, username, isStar): boolean => {
const isExistlocalUsers = _.isNil(localUsers[username]) === false;

View file

@ -5,9 +5,10 @@ import { errorUtils } from '@verdaccio/core';
import { Manifest, Version } from '@verdaccio/types';
import { HTTP_STATUS, USERS } from '../../../lib/constants';
import { $NextFunctionVer, $RequestExtend, IStorageHandler } from '../../../types';
import Storage from '../../../lib/storage';
import { $NextFunctionVer, $RequestExtend } from '../../../types';
export default function (route: Router, storage: IStorageHandler): void {
export default function (route: Router, storage: Storage): void {
route.get(
'/-/_view/starredByUser',
(req: $RequestExtend, res: Response, next: $NextFunctionVer): void => {

View file

@ -7,13 +7,14 @@ import { rateLimit } from '@verdaccio/middleware';
import { Config, RemoteUser } from '@verdaccio/types';
import { createSessionToken, getAuthenticatedMessage } from '@verdaccio/utils';
import Auth from '../../../lib/auth';
import { getApiToken, validatePassword } from '../../../lib/auth-utils';
import { API_ERROR, API_MESSAGE, HEADERS, HTTP_STATUS } from '../../../lib/constants';
import { logger } from '../../../lib/logger';
import { ErrorCode } from '../../../lib/utils';
import { $NextFunctionVer, $RequestExtend, $ResponseExtend, IAuth } from '../../../types';
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../../../types';
export default function (route: Router, auth: IAuth, config: Config): void {
export default function (route: Router, auth: Auth, config: Config): void {
/* eslint new-cap:off */
const userRouter = express.Router();

View file

@ -2,11 +2,13 @@ import { Response, Router } from 'express';
import _ from 'lodash';
import { rateLimit } from '@verdaccio/middleware';
import { ConfigYaml } from '@verdaccio/types';
import Auth from '../../../../lib/auth';
import { validatePassword } from '../../../../lib/auth-utils';
import { API_ERROR, APP_ERROR, HTTP_STATUS, SUPPORT_ERRORS } from '../../../../lib/constants';
import { ErrorCode } from '../../../../lib/utils';
import { $NextFunctionVer, $RequestExtend, IAuth } from '../../../../types';
import { $NextFunctionVer, $RequestExtend } from '../../../../types';
export interface Profile {
tfa: boolean;
@ -19,7 +21,7 @@ export interface Profile {
fullname: string;
}
export default function (auth: IAuth, config): Router {
export default function (auth: Auth, config: ConfigYaml): Router {
const profileRoute = Router(); /* eslint new-cap: 0 */
function buildProfile(name: string): Profile {
return {

View file

@ -6,11 +6,13 @@ import { rateLimit } from '@verdaccio/middleware';
import { Config, RemoteUser, Token } from '@verdaccio/types';
import { stringToMD5 } from '@verdaccio/utils';
import Auth from '../../../../lib/auth';
import { getApiToken } from '../../../../lib/auth-utils';
import { HEADERS, HTTP_STATUS, SUPPORT_ERRORS } from '../../../../lib/constants';
import { logger } from '../../../../lib/logger';
import Storage from '../../../../lib/storage';
import { ErrorCode, mask } from '../../../../lib/utils';
import { $NextFunctionVer, $RequestExtend, IAuth, IStorageHandler } from '../../../../types';
import { $NextFunctionVer, $RequestExtend } from '../../../../types';
const debug = buildDebug('verdaccio:token');
export type NormalizeToken = Token & {
@ -25,7 +27,7 @@ function normalizeToken(token: Token): NormalizeToken {
}
// https://github.com/npm/npm-profile/blob/latest/lib/index.js
export default function (auth: IAuth, storage: IStorageHandler, config: Config): Router {
export default function (auth: Auth, storage: Storage, config: Config): Router {
const tokenRoute = Router(); /* eslint new-cap: 0 */
tokenRoute.get(
'/tokens',

View file

@ -2,7 +2,8 @@ import express from 'express';
import { Config } from '@verdaccio/types';
import { IAuth, IStorageHandler } from '../../types';
import Auth from '../../lib/auth';
import Storage from '../../lib/storage';
import distTags from './api/dist-tags';
import pkg from './api/package';
import ping from './api/ping';
@ -22,7 +23,7 @@ const {
antiLoop,
} = require('@verdaccio/middleware');
export default function (config: Config, auth: IAuth, storage: IStorageHandler) {
export default function (config: Config, auth: Auth, storage: Storage) {
/* eslint new-cap:off */
const app = express.Router();
/* eslint new-cap:off */

View file

@ -3,10 +3,11 @@ import cors from 'cors';
import express, { Application } from 'express';
import _ from 'lodash';
import { getUserAgent } from '@verdaccio/config';
import { Config, getUserAgent } from '@verdaccio/config';
import { pluginUtils } from '@verdaccio/core';
import { final } from '@verdaccio/middleware';
import { log } from '@verdaccio/middleware';
import { Config as IConfig, IPluginMiddleware, IPluginStorageFilter } from '@verdaccio/types';
import { Config as IConfig } from '@verdaccio/types';
import Auth from '../lib/auth';
import AppConfig from '../lib/config';
@ -15,13 +16,7 @@ import { logger, setup } from '../lib/logger';
import loadPlugin from '../lib/plugin-loader';
import Storage from '../lib/storage';
import { ErrorCode } from '../lib/utils';
import {
$NextFunctionVer,
$RequestExtend,
$ResponseExtend,
IAuth,
IStorageHandler,
} from '../types';
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';
import hookDebug from './debug';
import apiEndpoint from './endpoint';
import { errorReportingMiddleware, handleError, serveFavicon } from './middleware';
@ -45,8 +40,8 @@ export function loadTheme(config) {
}
}
const defineAPI = function (config: IConfig, storage: IStorageHandler): any {
const auth: IAuth = new Auth(config);
const defineAPI = function (config: IConfig, storage: Storage): any {
const auth = new Auth(config);
const app: Application = express();
// run in production mode by default, just in case
@ -65,7 +60,7 @@ const defineAPI = function (config: IConfig, storage: IStorageHandler): any {
app.use(log(logger));
app.use(errorReportingMiddleware);
if (config.user_agent) {
app.use(function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
app.use(function (_req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
res.setHeader('X-Powered-By', getUserAgent(config.user_agent));
next();
});
@ -79,7 +74,7 @@ const defineAPI = function (config: IConfig, storage: IStorageHandler): any {
// Hook for tests only
if (config._debug) {
hookDebug(app, config.self_path);
hookDebug(app, config.configPath);
}
// register middleware plugins
@ -88,15 +83,16 @@ const defineAPI = function (config: IConfig, storage: IStorageHandler): any {
logger: logger,
};
const plugins: IPluginMiddleware<IConfig>[] = loadPlugin(
const plugins: pluginUtils.Auth<IConfig>[] = loadPlugin(
config,
config.middlewares,
plugin_params,
function (plugin: IPluginMiddleware<IConfig>) {
function (plugin: pluginUtils.ManifestFilter<IConfig>) {
// @ts-expect-error
return plugin.register_middlewares;
}
);
plugins.forEach((plugin: IPluginMiddleware<IConfig>) => {
plugins.forEach((plugin: any) => {
plugin.register_middlewares(app, auth, storage);
});
@ -138,9 +134,10 @@ export default (async function (configHash: any): Promise<any> {
config,
config.filters || {},
plugin_params,
(plugin: IPluginStorageFilter<IConfig>) => plugin.filter_metadata
// @ts-ignore
(plugin: pluginUtils.ManifestFilter<IConfig>) => plugin.filter_metadata
);
const storage: IStorageHandler = new Storage(config);
const storage = new Storage(config);
// waits until init calls have been initialized
await storage.init(config, filters);
return defineAPI(config, storage);

View file

@ -9,8 +9,10 @@ import {
import { Config, Package } from '@verdaccio/types';
import { generateGravatarUrl } from '@verdaccio/utils';
import Auth from '../../../lib/auth';
import { DIST_TAGS, HEADERS, HEADER_TYPE, HTTP_STATUS } from '../../../lib/constants';
import { logger } from '../../../lib/logger';
import Storage from '../../../lib/storage';
import {
ErrorCode,
addGravatarSupport,
@ -21,14 +23,7 @@ import {
parseReadme,
sortByName,
} from '../../../lib/utils';
import {
$NextFunctionVer,
$RequestExtend,
$ResponseExtend,
$SidebarPackage,
IAuth,
IStorageHandler,
} from '../../../types';
import { $NextFunctionVer, $RequestExtend, $ResponseExtend, $SidebarPackage } from '../../../types';
const getOrder = (order = 'asc') => {
return order === 'asc';
@ -36,7 +31,7 @@ const getOrder = (order = 'asc') => {
export type PackcageExt = Package & { author: any; dist?: { tarball: string } };
function addPackageWebApi(storage: IStorageHandler, auth: IAuth, config: Config): Router {
function addPackageWebApi(storage: Storage, auth: Auth, config: Config): Router {
const can = allow(auth, {
beforeAll: (params, message) => {
logger.debug(params, message);

View file

@ -2,17 +2,13 @@ import { Router } from 'express';
import { Package } from '@verdaccio/types';
import Auth from '../../../lib/auth';
import { DIST_TAGS } from '../../../lib/constants';
import Search from '../../../lib/search';
import {
$NextFunctionVer,
$RequestExtend,
$ResponseExtend,
IAuth,
IStorageHandler,
} from '../../../types';
import Storage from '../../../lib/storage';
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../../../types';
function addSearchWebApi(storage: IStorageHandler, auth: IAuth): Router {
function addSearchWebApi(storage: Storage, auth: Auth): Router {
const route = Router(); /* eslint new-cap: 0 */
// Search package
route.get(

View file

@ -3,12 +3,13 @@ import _ from 'lodash';
import { Config, JWTSignOptions, RemoteUser } from '@verdaccio/types';
import Auth from '../../../lib/auth';
import { getSecurity, validatePassword } from '../../../lib/auth-utils';
import { API_ERROR, APP_ERROR, HEADERS, HTTP_STATUS } from '../../../lib/constants';
import { ErrorCode } from '../../../lib/utils';
import { $NextFunctionVer, IAuth } from '../../../types';
import { $NextFunctionVer } from '../../../types';
function addUserAuthApi(auth: IAuth, config: Config): Router {
function addUserAuthApi(auth: Auth, config: Config): Router {
const route = Router(); /* eslint new-cap: 0 */
route.post('/login', function (req: Request, res: Response, next: $NextFunctionVer): void {
const { username, password } = req.body;

View file

@ -2,12 +2,12 @@ import buildDebug from 'debug';
import _ from 'lodash';
import { createAnonymousRemoteUser } from '@verdaccio/config';
import { pluginUtils } from '@verdaccio/core';
import { aesDecryptDeprecated as aesDecrypt, verifyPayload } from '@verdaccio/signature';
import {
APITokenOptions,
Callback,
Config,
IPluginAuth,
JWTOptions,
Package,
RemoteUser,
@ -79,7 +79,7 @@ export function handleSpecialUnpublish(): any {
};
}
export function getDefaultPlugins(logger: any): IPluginAuth<Config> {
export function getDefaultPlugins(logger: any): pluginUtils.Auth<Config> {
return {
authenticate(_user: string, _password: string, cb: Callback): void {
// pragma: allowlist secret

View file

@ -3,13 +3,12 @@ import { NextFunction } from 'express';
import _ from 'lodash';
import { createAnonymousRemoteUser, createRemoteUser } from '@verdaccio/config';
import { VerdaccioError, pluginUtils } from '@verdaccio/core';
import { aesEncryptDeprecated as aesEncrypt, signPayload } from '@verdaccio/signature';
import {
AllowAccess,
AuthPluginPackage,
Callback,
Config,
IPluginAuth,
JWTSignOptions,
Logger,
PackageAccess,
@ -19,7 +18,7 @@ import {
import { getMatchedPackagesSpec } from '@verdaccio/utils';
import loadPlugin from '../lib/plugin-loader';
import { $RequestExtend, $ResponseExtend, AESPayload, IAuth } from '../types';
import { $RequestExtend, $ResponseExtend, AESPayload } from '../types';
import {
getDefaultPlugins,
getMiddlewareCredentials,
@ -36,11 +35,11 @@ import { ErrorCode, convertPayloadToBase64 } from './utils';
const debug = buildDebug('verdaccio:auth');
class Auth implements IAuth {
class Auth {
public config: Config;
public logger: Logger;
public secret: string; // pragma: allowlist secret
public plugins: IPluginAuth<Config>[];
public secret: string;
public plugins: pluginUtils.Auth<Config>[];
public constructor(config: Config) {
this.config = config;
@ -50,17 +49,17 @@ class Auth implements IAuth {
this._applyDefaultPlugins();
}
private _loadPlugin(config: Config): IPluginAuth<Config>[] {
private _loadPlugin(config: Config): pluginUtils.Auth<Config>[] {
const pluginOptions = {
config,
logger: this.logger,
};
return loadPlugin<IPluginAuth<Config>>(
return loadPlugin<pluginUtils.Auth<Config>>(
config,
config.auth,
pluginOptions,
(plugin: IPluginAuth<Config>): boolean => {
(plugin: pluginUtils.Auth<Config>): boolean => {
const { authenticate, allow_access, allow_publish } = plugin;
// @ts-ignore
return authenticate || allow_access || allow_publish;
@ -110,7 +109,7 @@ class Auth implements IAuth {
const plugins = this.plugins.slice(0);
const self = this;
(function next(): void {
const plugin = plugins.shift() as IPluginAuth<Config>;
const plugin = plugins.shift() as pluginUtils.Auth<Config>;
if (_.isFunction(plugin.authenticate) === false) {
return next();
}
@ -153,7 +152,7 @@ class Auth implements IAuth {
const plugins = this.plugins.slice(0);
debug('add user %o', user);
(function next(): void {
const plugin = plugins.shift() as IPluginAuth<Config>;
const plugin = plugins.shift() as pluginUtils.Auth<Config>;
let method = 'adduser';
if (_.isFunction(plugin[method]) === false) {
method = 'add_user';
@ -188,7 +187,7 @@ class Auth implements IAuth {
* Allow user to access a package.
*/
public allow_access(
{ packageName, packageVersion }: AuthPluginPackage,
{ packageName, packageVersion }: pluginUtils.AuthPluginPackage,
user: RemoteUser,
callback: Callback
): void {
@ -203,13 +202,13 @@ class Auth implements IAuth {
debug('allow access for %o', packageName);
(function next(): void {
const plugin: IPluginAuth<Config> = plugins.shift() as IPluginAuth<Config>;
const plugin: pluginUtils.Auth<unknown> = plugins.shift() as pluginUtils.Auth<Config>;
if (_.isNil(plugin) || _.isFunction(plugin.allow_access) === false) {
return next();
}
plugin.allow_access!(user, pkg, function (err, ok: boolean): void {
plugin.allow_access!(user, pkg, function (err: VerdaccioError | null, ok?: boolean): void {
if (err) {
self.logger.error(
{ packageName, err },
@ -229,7 +228,7 @@ class Auth implements IAuth {
}
public allow_unpublish(
{ packageName, packageVersion }: AuthPluginPackage,
{ packageName, packageVersion }: pluginUtils.AuthPluginPackage,
user: RemoteUser,
callback: Callback
): void {
@ -243,6 +242,7 @@ class Auth implements IAuth {
debug('allow unpublish for %o plugin does not implement allow_unpublish', packageName);
continue;
} else {
// @ts-ignore
plugin.allow_unpublish!(user, pkg, (err, ok: boolean): void => {
if (err) {
this.logger.error(
@ -275,7 +275,7 @@ class Auth implements IAuth {
* Allow user to publish a package.
*/
public allow_publish(
{ packageName, packageVersion }: AuthPluginPackage,
{ packageName, packageVersion }: pluginUtils.AuthPluginPackage,
user: RemoteUser,
callback: Callback
): void {
@ -317,7 +317,7 @@ class Auth implements IAuth {
})();
}
public apiJWTmiddleware(): Function {
public apiJWTmiddleware() {
const plugins = this.plugins.slice(0);
const helpers = { createAnonymousRemoteUser, createRemoteUser };
for (const plugin of plugins) {

View file

@ -54,11 +54,9 @@ export class InitCommand extends Command {
private initLogger(logConfig: ConfigYaml) {
if (logConfig.logs) {
// @ts-expect-error
logConfig.log = logConfig.logs;
warningUtils.emit(warningUtils.Codes.VERWAR002);
}
// @ts-expect-error
logger.setup(logConfig.log);
}

View file

@ -1,4 +1,3 @@
import assert from 'assert';
import _ from 'lodash';
import { PackageList } from '@verdaccio/types';
@ -46,41 +45,3 @@ export function hasProxyTo(pkg: string, upLink: string, packages: PackageList):
return false;
}
export function normalisePackageAccess(packages: LegacyPackageList): LegacyPackageList {
const normalizedPkgs: LegacyPackageList = { ...packages };
// add a default rule for all packages to make writing plugins easier
if (_.isNil(normalizedPkgs['**'])) {
normalizedPkgs['**'] = { access: [], publish: [], proxy: [] };
}
for (const pkg in packages) {
if (Object.prototype.hasOwnProperty.call(packages, pkg)) {
assert(
_.isObject(packages[pkg]) && _.isArray(packages[pkg]) === false,
`CONFIG: bad "'${pkg}'" package description (object expected)`
);
normalizedPkgs[pkg].access = normalizeUserList(
packages[pkg].allow_access,
packages[pkg].access
);
delete normalizedPkgs[pkg].allow_access;
normalizedPkgs[pkg].publish = normalizeUserList(
packages[pkg].allow_publish,
packages[pkg].publish
);
delete normalizedPkgs[pkg].allow_publish;
normalizedPkgs[pkg].proxy = normalizeUserList(
packages[pkg].proxy_access,
packages[pkg].proxy
);
delete normalizedPkgs[pkg].proxy_access;
// if unpublish is not defined, we set to false to fallback in publish access
normalizedPkgs[pkg].unpublish = _.isUndefined(packages[pkg].unpublish)
? false
: normalizeUserList([], packages[pkg].unpublish);
}
}
return normalizedPkgs;
}

View file

@ -3,18 +3,14 @@ import builDebug from 'debug';
import _ from 'lodash';
import UrlNode from 'url';
import { pluginUtils } from '@verdaccio/core';
import LocalDatabase from '@verdaccio/local-storage';
import { ReadTarball, UploadTarball } from '@verdaccio/streams';
import {
Author,
Callback,
CallbackAction,
Config,
DistFile,
IPackageStorage,
IPluginStorage,
IReadTarball,
IUploadTarball,
Logger,
MergeTags,
Package,
@ -32,8 +28,9 @@ import {
validateName,
} from '@verdaccio/utils';
import { StoragePluginLegacy } from '../../types/custom';
import loadPlugin from '../lib/plugin-loader';
import { IStorage, StringValue } from '../types';
import { StringValue } from '../types';
import { API_ERROR, DIST_TAGS, HTTP_STATUS, STORAGE, SUPPORT_ERRORS, USERS } from './constants';
import {
cleanUpReadme,
@ -46,12 +43,13 @@ import { prepareSearchPackage } from './storage-utils';
import { ErrorCode, isObject, tagVersion } from './utils';
const debug = builDebug('verdaccio:local-storage');
type StoragePlugin = StoragePluginLegacy<Config> | any;
/**
* Implements Storage interface (same for storage.js, local-storage.js, up-storage.js).
*/
class LocalStorage implements IStorage {
class LocalStorage {
public config: Config;
public storagePlugin: IPluginStorage<Config>;
public storagePlugin: StoragePlugin;
public logger: Logger;
public constructor(config: Config, logger: Logger) {
@ -108,7 +106,6 @@ class LocalStorage implements IStorage {
}
data = normalizePackage(data);
this.storagePlugin.remove(name, (removeFailed: Error): void => {
if (removeFailed) {
// This will happen when database is locked
@ -235,7 +232,7 @@ class LocalStorage implements IStorage {
version: string,
metadata: Version,
tag: StringValue,
callback: CallbackAction
callback: Callback
): void {
this._updatePackage(
name,
@ -306,7 +303,7 @@ class LocalStorage implements IStorage {
* @param {*} tags
* @param {*} callback
*/
public mergeTags(pkgName: string, tags: MergeTags, callback: CallbackAction): void {
public mergeTags(pkgName: string, tags: MergeTags, callback: Callback): void {
this._updatePackage(
pkgName,
(data, cb): void => {
@ -370,7 +367,7 @@ class LocalStorage implements IStorage {
debug('changePackage udapting package for %o', name);
this._updatePackage(
name,
(localData: Package, cb: CallbackAction): void => {
(localData: Package, cb: Callback): void => {
for (const version in localData.versions) {
const incomingVersion = incomingPkg.versions[version];
if (_.isNil(incomingVersion)) {
@ -425,12 +422,7 @@ class LocalStorage implements IStorage {
* @param {*} revision
* @param {*} callback
*/
public removeTarball(
name: string,
filename: string,
revision: string,
callback: CallbackAction
): void {
public removeTarball(name: string, filename: string, revision: string, callback: Callback): void {
assert(validateName(filename));
this._updatePackage(
@ -462,12 +454,12 @@ class LocalStorage implements IStorage {
* @param {String} filename
* @return {Stream}
*/
public addTarball(name: string, filename: string): IUploadTarball {
public addTarball(name: string, filename: string) {
assert(validateName(filename));
let length = 0;
const shaOneHash = createTarballHash();
const uploadStream: IUploadTarball = new UploadTarball({});
const uploadStream = new UploadTarball({});
const _transform = uploadStream._transform;
const storage = this._getLocalStorage(name);
@ -498,7 +490,7 @@ class LocalStorage implements IStorage {
return uploadStream;
}
const writeStream: IUploadTarball = storage.writeTarball(filename);
const writeStream = storage.writeTarball(filename);
writeStream.on('error', (err) => {
// @ts-ignore
@ -568,10 +560,10 @@ class LocalStorage implements IStorage {
* @param {*} filename
* @return {ReadTarball}
*/
public getTarball(name: string, filename: string): IReadTarball {
public getTarball(name: string, filename: string) {
assert(validateName(filename));
const storage: IPackageStorage = this._getLocalStorage(name);
const storage = this._getLocalStorage(name);
if (_.isNil(storage)) {
return this._createFailureStreamResponse();
@ -585,8 +577,8 @@ class LocalStorage implements IStorage {
* @private
* @return {ReadTarball}
*/
private _createFailureStreamResponse(): IReadTarball {
const stream: IReadTarball = new ReadTarball({});
private _createFailureStreamResponse() {
const stream = new ReadTarball({});
process.nextTick((): void => {
stream.emit('error', this._getFileNotAvailable());
@ -601,8 +593,8 @@ class LocalStorage implements IStorage {
* @private
* @return {ReadTarball}
*/
private _streamSuccessReadTarBall(storage: any, filename: string): IReadTarball {
const stream: IReadTarball = new ReadTarball({});
private _streamSuccessReadTarBall(storage: any, filename: string) {
const stream = new ReadTarball({});
const readTarballStream = storage.readTarball(filename);
const e404 = ErrorCode.getNotFound;
@ -641,7 +633,7 @@ class LocalStorage implements IStorage {
* @return {Function}
*/
public getPackageMetadata(name: string, callback: Callback = (): void => {}): void {
const storage: IPackageStorage = this._getLocalStorage(name);
const storage = this._getLocalStorage(name);
if (_.isNil(storage)) {
return callback(ErrorCode.getNotFound());
}
@ -655,11 +647,11 @@ class LocalStorage implements IStorage {
* @param {*} options
* @return {Function}
*/
public search(startKey: string, options: any): IReadTarball {
public search(startKey: string, options: any) {
const stream = new ReadTarball({ objectMode: true });
this._searchEachPackage(
(item: Package, cb: CallbackAction): void => {
(item: Package, cb: Callback): void => {
// @ts-ignore
if (item.time > parseInt(startKey, 10)) {
this.getPackageMetadata(item.name, (err: any, data: Package): void => {
@ -696,7 +688,7 @@ class LocalStorage implements IStorage {
* @param {Object} pkgName package name.
* @return {Object}
*/
private _getLocalStorage(pkgName: string): IPackageStorage {
private _getLocalStorage(pkgName: string) {
return this.storagePlugin.getPackageStorage(pkgName);
}
@ -786,9 +778,9 @@ class LocalStorage implements IStorage {
private _updatePackage(
name: string,
updateHandler: StorageUpdateCallback,
callback: CallbackAction
callback: Callback
): void {
const storage: IPackageStorage = this._getLocalStorage(name);
const storage = this._getLocalStorage(name);
if (!storage) {
return callback(ErrorCode.getNotFound());
@ -874,34 +866,34 @@ class LocalStorage implements IStorage {
}
}
public async getSecret(config: Config): Promise<void> {
public async getSecret(config: Config): Promise<string> {
const secretKey = await this.storagePlugin.getSecret();
return this.storagePlugin.setSecret(config.checkSecretKey(secretKey));
}
private _loadStorage(config: Config, logger: Logger): IPluginStorage<Config> {
private _loadStorage(config: Config, logger: Logger): StoragePlugin {
const Storage = this._loadStorePlugin();
if (_.isNil(Storage)) {
assert(this.config.storage, 'CONFIG: storage path not defined');
assert(this.config.storage, 'CONFIG: storage default path not defined');
return new LocalDatabase(this.config, logger);
}
return Storage as IPluginStorage<Config>;
return Storage as StoragePlugin;
}
private _loadStorePlugin(): IPluginStorage<Config> | void {
private _loadStorePlugin(): StoragePlugin | void {
const plugin_params = {
config: this.config,
logger: this.logger,
};
// eslint-disable-next-line max-len
const plugins: IPluginStorage<Config>[] = loadPlugin<IPluginStorage<Config>>(
const plugins: StoragePlugin[] = loadPlugin<StoragePlugin>(
this.config,
this.config.store,
plugin_params,
(plugin): IPluginStorage<Config> => {
(plugin): StoragePlugin => {
return plugin.getPackageStorage;
}
);

View file

@ -2,7 +2,8 @@ import buildDebug from 'debug';
import _ from 'lodash';
import Path from 'path';
import { Config, IPlugin } from '@verdaccio/types';
import { pluginUtils } from '@verdaccio/core';
import { Config } from '@verdaccio/types';
import { MODULE_NOT_FOUND } from './constants';
import { logger } from './logger';
@ -55,14 +56,14 @@ function isES6(plugin): boolean {
* @param {*} sanityCheck callback that check the shape that should fulfill the plugin
* @return {Array} list of plugins
*/
export default function loadPlugin<T extends IPlugin<T>>(
export default function loadPlugin<T extends pluginUtils.Plugin<T>>(
config: Config,
pluginConfigs: any = {},
params: any,
sanityCheck: any,
prefix: string = 'verdaccio'
): any[] {
return Object.keys(pluginConfigs).map((pluginId: string): IPlugin<T> => {
return Object.keys(pluginConfigs).map((pluginId: string): pluginUtils.Plugin<T> => {
let plugin;
const isScoped: boolean = pluginId.startsWith('@') && pluginId.includes('/');
debug('isScoped %s', isScoped);
@ -114,7 +115,8 @@ export default function loadPlugin<T extends IPlugin<T>>(
// relative to config path
if (plugin === null && pluginId.match(/^\.\.?($|\/)/)) {
plugin = tryLoad(Path.resolve(Path.dirname(config.self_path), pluginId));
// compatible with 6.x
plugin = tryLoad(Path.resolve(Path.dirname(config.self_path ?? config.configPath), pluginId));
}
if (plugin === null) {

View file

@ -6,7 +6,7 @@ import https from 'https';
import _, { assign } from 'lodash';
import path from 'path';
import { ConfigRuntime, HttpsConfKeyCert, HttpsConfPfx } from '@verdaccio/types';
import { Config, HttpsConfKeyCert, HttpsConfPfx } from '@verdaccio/types';
import endPointAPI from '../api/index';
import { getListListenAddresses } from './cli/utils';
@ -85,7 +85,7 @@ export async function runServer(config?: string): Promise<any> {
* @param addr
* @param app
*/
export function createServerFactory(config: ConfigRuntime, addr, app) {
export function createServerFactory(config: Config, addr, app) {
let serverFactory;
if (addr.proto === 'https') {
debug('https enabled');

View file

@ -3,7 +3,9 @@ import lunrMutable from 'lunr-mutable-indexes';
import { Version } from '@verdaccio/types';
import { IStorage, IStorageHandler, IWebSearch } from '../types';
import { IWebSearch } from '../types';
import LocalStorage from './local-storage';
import Storage from './storage';
/**
* Handle the search Indexer.
@ -11,7 +13,7 @@ import { IStorage, IStorageHandler, IWebSearch } from '../types';
class Search implements IWebSearch {
public index: lunrMutable.index;
// @ts-ignore
public storage: IStorageHandler;
public storage: Storage;
/**
* Constructor.
@ -43,7 +45,7 @@ class Search implements IWebSearch {
* @return {Array} list of results.
*/
public query(query: string): any[] {
const localStorage = this.storage.localStorage as IStorage;
const localStorage = this.storage.localStorage as LocalStorage;
const hasScope = query.startsWith('@');
// FIXME: lunr-mutable-indexes ignored '@' during indexing
@ -106,7 +108,7 @@ class Search implements IWebSearch {
* Set up the {Storage}
* @param {*} storage An storage reference.
*/
public configureStorage(storage: IStorageHandler): void {
public configureStorage(storage: Storage): void {
this.storage = storage;
this.reindex();
}

View file

@ -10,8 +10,8 @@ import {
} from '@verdaccio/types';
import { generateRandomHexString } from '@verdaccio/utils';
import { IStorage } from '../types';
import { API_ERROR, DIST_TAGS, HTTP_STATUS, STORAGE, USERS } from './constants';
import LocalStorage from './local-storage';
import Search from './search';
import { ErrorCode, isObject, normalizeDistTags, semverSort } from './utils';
@ -128,7 +128,7 @@ export function cleanUpLinksRef(keepUpLinkData: boolean, result: Package): Packa
* @param {*} name
* @param {*} localStorage
*/
export function checkPackageLocal(name: string, localStorage: IStorage): Promise<void> {
export function checkPackageLocal(name: string, localStorage: LocalStorage): Promise<void> {
return new Promise((resolve, reject): void => {
localStorage.getPackageMetadata(name, (err, results): void => {
if (!_.isNil(err) && err.status !== HTTP_STATUS.NOT_FOUND) {
@ -142,7 +142,11 @@ export function checkPackageLocal(name: string, localStorage: IStorage): Promise
});
}
export function publishPackage(name: string, metadata: any, localStorage: IStorage): Promise<void> {
export function publishPackage(
name: string,
metadata: any,
localStorage: LocalStorage
): Promise<void> {
return new Promise((resolve, reject): void => {
localStorage.addPackage(name, metadata, (err, latest): void => {
if (!_.isNull(err)) {

View file

@ -9,9 +9,8 @@ import {
Callback,
Config,
DistFile,
IReadTarball,
IUploadTarball,
Logger,
Manifest,
MergeTags,
Package,
Version,
@ -20,16 +19,7 @@ import {
import { GenericBody, Token, TokenFilter } from '@verdaccio/types';
import { logger } from '../lib/logger';
import {
IGetPackageOptions,
IPluginFilters,
IProxy,
IStorage,
IStorageHandler,
ISyncUplinks,
ProxyList,
StringValue,
} from '../types';
import { IPluginFilters, ISyncUplinks, StringValue } from '../types';
import { hasProxyTo } from './config-utils';
import { API_ERROR, DIST_TAGS, HTTP_STATUS } from './constants';
import LocalStorage from './local-storage';
@ -48,11 +38,11 @@ import ProxyStorage from './up-storage';
import { setupUpLinks, updateVersionsHiddenUpLink } from './uplink-util';
import { ErrorCode, isObject, normalizeDistTags } from './utils';
class Storage implements IStorageHandler {
public localStorage: IStorage;
class Storage {
public localStorage: LocalStorage;
public config: Config;
public logger: Logger;
public uplinks: ProxyList;
public uplinks: Record<string, ProxyStorage>;
public filters: IPluginFilters;
public constructor(config: Config) {
@ -85,7 +75,7 @@ class Storage implements IStorageHandler {
this._isAllowPublishOffline(),
this._syncUplinksMetadata.bind(this)
);
await publishPackage(name, metadata, this.localStorage as IStorage);
await publishPackage(name, metadata, this.localStorage);
callback();
} catch (err: any) {
callback(err);
@ -175,7 +165,7 @@ class Storage implements IStorageHandler {
Function is synchronous and returns a WritableStream
Used storages: local (write)
*/
public addTarball(name: string, filename: string): IUploadTarball {
public addTarball(name: string, filename: string) {
return this.localStorage.addTarball(name, filename);
}
@ -211,7 +201,7 @@ class Storage implements IStorageHandler {
information in order to figure out where we can get this tarball from
Used storages: local || uplink (just one)
*/
public getTarball(name: string, filename: string): IReadTarball {
public getTarball(name: string, filename: string) {
const readStream = new ReadTarball({});
readStream.abort = function () {};
@ -284,7 +274,7 @@ class Storage implements IStorageHandler {
);
}
let savestream: IUploadTarball | null = null;
let savestream: any = null;
if (uplink.config.cache) {
savestream = self.localStorage.addTarball(name, filename);
}
@ -353,7 +343,7 @@ class Storage implements IStorageHandler {
* @property {boolean} options.keepUpLinkData keep up link info in package meta, last update, etc.
* @property {function} options.callback Callback for receive data
*/
public getPackage(options: IGetPackageOptions): void {
public getPackage(options): void {
this.localStorage.getPackageMetadata(options.name, (err, data): void => {
if (err && (!err.status || err.status >= HTTP_STATUS.INTERNAL_ERROR)) {
// report internal errors right away
@ -395,7 +385,7 @@ class Storage implements IStorageHandler {
* @param {*} options
* @return {Stream}
*/
public search(startkey: string, options: any): IReadTarball {
public search(startkey: string, options: any) {
const self = this;
const searchStream: any = new Stream.PassThrough({ objectMode: true });
async.eachSeries(
@ -407,7 +397,7 @@ class Storage implements IStorageHandler {
}
logger.info(`search for uplink ${up_name}`);
// search by keyword for each uplink
const uplinkStream: IUploadTarball = self.uplinks[up_name].search(options);
const uplinkStream = self.uplinks[up_name].search(options);
// join uplink stream with streams PassThrough
uplinkStream.pipe(searchStream, { end: false });
uplinkStream.on('error', function (err): void {
@ -434,7 +424,7 @@ class Storage implements IStorageHandler {
// executed after all series
function (): void {
// attach a local search results
const localSearchStream: IReadTarball = self.localStorage.search(startkey, options);
const localSearchStream = self.localStorage.search(startkey, options);
searchStream.abort = function (): void {
localSearchStream.abort();
};
@ -511,13 +501,13 @@ class Storage implements IStorageHandler {
*/
public _syncUplinksMetadata(
name: string,
packageInfo: Package,
packageInfo: Manifest,
options: ISyncUplinks,
callback: Callback
): void {
let found = true;
const self = this;
const upLinks: IProxy[] = [];
const upLinks: ProxyStorage[] = [];
const hasToLookIntoUplinks = _.isNil(options.uplinksLook) || options.uplinksLook;
if (!packageInfo) {
@ -533,7 +523,7 @@ class Storage implements IStorageHandler {
async.map(
upLinks,
(upLink, cb): void => {
(upLink: ProxyStorage, cb): void => {
const _options = Object.assign({}, options);
const upLinkMeta = packageInfo._uplinks[upLink.upname];
@ -662,7 +652,7 @@ class Storage implements IStorageHandler {
* @param {String} upLink uplink name
* @private
*/
public _updateVersionsHiddenUpLink(versions: Versions, upLink: IProxy): void {
public _updateVersionsHiddenUpLink(versions: Versions, upLink: ProxyStorage): void {
for (const i in versions) {
if (Object.prototype.hasOwnProperty.call(versions, i)) {
const version = versions[i];

View file

@ -7,10 +7,9 @@ import URL, { UrlWithStringQuery } from 'url';
import zlib from 'zlib';
import { ReadTarball } from '@verdaccio/streams';
import { Callback, Config, Headers, Logger, Package } from '@verdaccio/types';
import { Callback, Config, Headers, Logger, Package, UpLinkConf } from '@verdaccio/types';
import { buildToken } from '@verdaccio/utils';
import { IProxy, UpLinkConfLocal } from '../types';
import {
API_ERROR,
CHARACTER_ENCODING,
@ -44,8 +43,8 @@ const setConfig = (config, key, def): string => {
* Implements Storage interface
* (same for storage.js, local-storage.js, up-storage.js)
*/
class ProxyStorage implements IProxy {
public config: UpLinkConfLocal;
class ProxyStorage {
public config: UpLinkConf;
public failed_requests: number;
public userAgent: string;
public ca: string | void;
@ -72,7 +71,7 @@ class ProxyStorage implements IProxy {
* @param {*} config
* @param {*} mainConfig
*/
public constructor(config: UpLinkConfLocal, mainConfig: Config) {
public constructor(config: UpLinkConf, mainConfig: Config) {
this.config = config;
this.failed_requests = 0;
// @ts-ignore
@ -140,7 +139,7 @@ class ProxyStorage implements IProxy {
const headers: Headers = this._setHeaders(options);
this._addProxyHeaders(options.req, headers);
this._overrideWithUpLinkConfLocaligHeaders(headers);
this._overrideWithUpLinkConfigHeaders(headers);
const method = options.method || 'GET';
const uri = options.uri_full || this.config.url + options.uri;
@ -391,7 +390,7 @@ class ProxyStorage implements IProxy {
* @param {Object} headers
* @private
*/
private _overrideWithUpLinkConfLocaligHeaders(headers: Headers): any {
private _overrideWithUpLinkConfigHeaders(headers: Headers): any {
if (!this.config.headers) {
return headers;
}
@ -468,7 +467,7 @@ class ProxyStorage implements IProxy {
* @param {String} url
* @return {Stream}
*/
fetchTarball(url: string) {
public fetchTarball(url: string) {
const stream = new ReadTarball({});
let current_length = 0;
let expected_length;
@ -522,7 +521,7 @@ class ProxyStorage implements IProxy {
* @param {*} options request options
* @return {Stream}
*/
public search(options: any): Stream.Readable {
public search(options: any) {
const transformStream: any = new Stream.PassThrough({ objectMode: true });
const requestStream: Stream.Readable = this.request({
uri: options.req.url,
@ -660,7 +659,7 @@ class ProxyStorage implements IProxy {
*/
private _setupProxy(
hostname: string,
config: UpLinkConfLocal,
config: UpLinkConf,
mainconfig: Config,
isHTTPS: boolean
): void {

View file

@ -1,18 +1,17 @@
import { Config, Versions } from '@verdaccio/types';
import { IProxy, ProxyList } from '../types';
import ProxyStorage from './up-storage';
/**
* Set up the Up Storage for each link.
*/
export function setupUpLinks(config: Config): ProxyList {
const uplinks: ProxyList = {};
export function setupUpLinks(config: Config): Record<string, ProxyStorage> {
const uplinks = {};
for (const uplinkName in config.uplinks) {
if (Object.prototype.hasOwnProperty.call(config.uplinks, uplinkName)) {
// instance for each up-link definition
const proxy: IProxy = new ProxyStorage(config.uplinks[uplinkName], config);
const proxy = new ProxyStorage(config.uplinks[uplinkName], config);
proxy.upname = uplinkName;
uplinks[uplinkName] = proxy;
@ -22,7 +21,7 @@ export function setupUpLinks(config: Config): ProxyList {
return uplinks;
}
export function updateVersionsHiddenUpLink(versions: Versions, upLink: IProxy): void {
export function updateVersionsHiddenUpLink(versions: Versions, upLink): void {
for (const i in versions) {
if (Object.prototype.hasOwnProperty.call(versions, i)) {
const version = versions[i];

View file

@ -1,32 +1,22 @@
import { NextFunction, Request, Response } from 'express';
import lunrMutable from 'lunr-mutable-indexes';
import { pluginUtils } from '@verdaccio/core';
import {
AuthPluginPackage,
Author,
Callback,
Config,
IBasicAuth,
IBasicStorage,
IPluginStorage,
IPluginStorageFilter,
IReadTarball,
IStorageManager,
ITokenActions,
JWTSignOptions,
Logger,
Package,
PackageAccess,
RateLimit,
RemoteUser,
Token,
TokenFilter,
UpLinkConf,
Version,
Versions,
StringValue as verdaccio$StringValue,
} from '@verdaccio/types';
import Storage from '../lib/storage';
export type StringValue = verdaccio$StringValue;
// legacy should be removed in long term
@ -63,10 +53,6 @@ export interface AuthTokenHeader {
export type BasicPayload = AESPayload | void;
export type AuthMiddlewarePayload = RemoteUser | BasicPayload;
export interface ProxyList {
[key: string]: IProxy;
}
export interface Utils {
ErrorCode: any;
getLatestVersion: Callback;
@ -103,63 +89,15 @@ interface IAuthMiddleware {
webUIJWTmiddleware(): $NextFunctionVer;
}
export interface IAuth extends IBasicAuth<Config>, IAuthMiddleware, IAuthWebUI {
config: Config;
logger: Logger;
secret: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
plugins: any[];
allow_unpublish(pkg: AuthPluginPackage, user: RemoteUser, callback: Callback): void;
}
export interface IWebSearch {
index: lunrMutable.index;
storage: IStorageHandler;
storage: Storage;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
query(query: string): any;
add(pkg: Version): void;
remove(name: string): void;
reindex(): void;
configureStorage(storage: IStorageHandler): void;
}
// FIXME: This prop should be on @verdaccio/types
export type UpLinkConfLocal = UpLinkConf & {
no_proxy?: string;
};
export interface IProxy {
config: UpLinkConfLocal;
failed_requests: number;
userAgent: string;
ca?: string | void;
logger: Logger;
server_id: string;
url: any;
maxage: number;
timeout: number;
max_fails: number;
fail_timeout: number;
upname: string;
fetchTarball(url: string): IReadTarball;
isUplinkValid(url: string): boolean;
search(options: any);
getRemoteMetadata(name: string, options: any, callback: Callback): void;
}
export interface IStorage extends IBasicStorage<Config>, ITokenActions {
config: Config;
storagePlugin: IPluginStorage<Config>;
logger: Logger;
}
export interface IGetPackageOptions {
callback: Callback;
name: string;
keepUpLinkData: boolean;
uplinksLook: boolean;
req: any;
abbreviated?: boolean;
configureStorage(storage: Storage): void;
}
export interface ISyncUplinks {
@ -168,20 +106,7 @@ export interface ISyncUplinks {
req?: Request;
}
export type IPluginFilters = IPluginStorageFilter<Config>[];
export interface IStorageHandler extends IStorageManager<Config>, ITokenActions {
config: Config;
localStorage: IStorage | null;
filters: IPluginFilters;
uplinks: ProxyList;
init(config: Config, filters: IPluginFilters): Promise<string>;
saveToken(token: Token): Promise<any>;
deleteToken(user: string, tokenKey: string): Promise<any>;
readTokens(filter: TokenFilter): Promise<Token[]>;
_syncUplinksMetadata(name: string, packageInfo: Package, options: any, callback: Callback): void;
_updateVersionsHiddenUpLink(versions: Versions, upLink: IProxy): void;
}
export type IPluginFilters = pluginUtils.ManifestFilter<Config>[];
/**
* @property { string | number | Styles } [ruleOrSelector]

View file

@ -3,26 +3,24 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable no-unused-vars */
import { pluginUtils } from '@verdaccio/core';
import { IReadTarball, IUploadTarball } from '@verdaccio/streams';
import { Package } from '@verdaccio/types';
import {
Config as AppConfig,
IBasicAuth,
IPluginMiddleware,
IStorageManager,
RemoteUser,
} from '@verdaccio/types';
import { Manifest } from '@verdaccio/types';
import { Config as AppConfig, RemoteUser } from '@verdaccio/types';
import Auth from '../../../../src/lib/auth';
import Config from '../../../../src/lib/config';
import Storage from '../../../../src/lib/storage';
import { generatePackageTemplate } from '../../../../src/lib/storage-utils';
import { readFile } from '../../../functional/lib/test.utils';
import { generateVersion } from '../../../unit/__helper/utils';
const readMetadata = (fileName: string): Package =>
JSON.parse(readFile(`../../unit/partials/${fileName}`).toString()) as Package;
const readMetadata = (fileName: string): Manifest =>
JSON.parse(readFile(`../../unit/partials/${fileName}`).toString()) as Manifest;
export default class ExampleMiddlewarePlugin implements IPluginMiddleware<{}> {
register_middlewares(app: any, auth: IBasicAuth<{}>, storage: IStorageManager<{}>): void {
// @ts-ignore
export default class ExampleMiddlewarePlugin implements pluginUtils.ManifestFilter<{}> {
register_middlewares(app: any, auth: Auth, storage: Storage): void {
const remoteUser: RemoteUser = {
groups: [],
real_groups: [],

View file

@ -1,181 +0,0 @@
// this file is not aim to be tested, just to check typescript definitions
import { ReadTarball, UploadTarball } from '@verdaccio/streams';
import {
Config as AppConfig,
Callback,
IReadTarball,
IUploadTarball,
Logger,
Package,
Token,
TokenFilter,
} from '@verdaccio/types';
import { IPackageStorage, IPackageStorageManager, IPluginStorage } from '@verdaccio/types';
import Config from '../../../../src/lib/config';
import { logger } from '../../../../src/lib/logger';
import { generatePackageTemplate } from '../../../../src/lib/storage-utils';
class PackageStorage implements IPackageStorageManager {
path: string;
logger: Logger;
constructor(path: string, logger: Logger) {
this.path = path;
this.logger = logger;
}
updatePackage(
name: string,
updateHandler: Callback,
onWrite: Callback,
transformPackage: Function,
onEnd: Callback
) {
onEnd();
}
deletePackage(fileName: string, callback: Callback) {
callback();
}
removePackage(callback: Callback): void {
callback();
}
createPackage(name: string, value: Package, cb: Callback) {
cb();
}
savePackage(name: string, value: Package, cb: Callback) {
cb();
}
readPackage(name: string, cb: Callback) {
cb();
}
writeTarball(name): IUploadTarball {
this.logger.debug({ name }, 'some name @name');
const uploadStream = new UploadTarball({});
uploadStream.on('close', () => {});
if (uploadStream.abort) {
uploadStream.abort();
}
if (uploadStream.done) {
uploadStream.done();
}
return uploadStream;
}
readTarball(name): IReadTarball {
this.logger.debug({ name }, 'some name @name');
const readTarballStream: IReadTarball = new ReadTarball({});
if (readTarballStream.abort) {
readTarballStream.abort();
}
return readTarballStream;
}
}
class ExampleStoragePlugin implements IPluginStorage<{}> {
logger: Logger;
config: AppConfig;
constructor(config: AppConfig, logger: Logger) {
this.config = config;
this.logger = logger;
}
saveToken(token: Token): Promise<any> {
return Promise.resolve(token);
}
deleteToken(user: string, tokenKey: string): Promise<any> {
return Promise.resolve([user, tokenKey]);
}
readTokens(filter: TokenFilter): Promise<Token[]> {
const token: Token = {
user: filter.user,
key: '12312',
token: '12321', // pragma: allowlist secret
readonly: false,
created: '123232',
};
return Promise.resolve([token, token]);
}
getSecret(): Promise<any> {
return Promise.resolve();
}
setSecret(secret: string): Promise<any> {
// pragma: allowlist secret
return Promise.resolve(secret); // pragma: allowlist secret
}
add(name: string, cb: Callback) {
cb();
}
remove(name: string, cb: Callback) {
cb();
}
get(cb: Callback) {
cb();
}
getPackageStorage(packageInfo: string): IPackageStorage {
return new PackageStorage(packageInfo, this.logger);
}
search(onPackage: Callback, onEnd: Callback, validateName: any): void {
onPackage(onEnd(validateName()));
}
}
export default ExampleStoragePlugin;
const config1: AppConfig = new Config({
storage: './storage',
self_path: '/home/sotrage',
});
const storage = new ExampleStoragePlugin(config1, logger.child());
storage.add('test', () => {});
storage.remove('test', () => {});
storage.getSecret().then(() => {});
storage.setSecret('newSecret').then(() => {});
storage.search(
() => {},
() => {},
'validateName'
);
storage.get(() => {});
const storageManager: IPackageStorage = storage.getPackageStorage('test');
if (storageManager) {
storageManager.createPackage('test', generatePackageTemplate('test'), () => {});
storageManager.savePackage('fileName', generatePackageTemplate('test'), () => {});
// @ts-ignore
storageManager.updatePackage(
'pkgFileName',
() => {},
() => {},
// @ts-ignore
() => {},
() => {}
);
storageManager.deletePackage('test', () => {});
storageManager.removePackage(() => {});
storageManager.readPackage('test', () => {});
storageManager.writeTarball('test');
}

View file

@ -10,7 +10,6 @@ import { logger, setup } from '../../../../src/lib/logger';
import { generatePackageTemplate } from '../../../../src/lib/storage-utils';
import { readFile } from '../../../functional/lib/test.utils';
import { generateNewVersion } from '../../../lib/utils-test';
import { IStorage } from '../../../types';
// @ts-ignore
import configExample from '../../partials/config';
@ -20,7 +19,7 @@ const readMetadata = (fileName = 'metadata') =>
setup([]);
describe('LocalStorage', () => {
let storage: IStorage;
let storage: LocalStorage;
const pkgName = 'npm_test';
const pkgNameScoped = `@scope/${pkgName}-scope`;
const tarballName = `${pkgName}-add-tarball-1.0.4.tgz`;

View file

@ -1,7 +1,9 @@
import _ from 'lodash';
import path from 'path';
import { hasProxyTo, normalisePackageAccess } from '../../../../src/lib/config-utils';
import { normalisePackageAccess } from '@verdaccio/config';
import { hasProxyTo } from '../../../../src/lib/config-utils';
import { parseConfigFile } from '../../../../src/lib/utils';
describe('Config Utilities', () => {

8
types/custom.d.ts vendored
View file

@ -1,4 +1,7 @@
/// <reference types="@verdaccio/types" />
import { ReadStream, WriteStream } from 'fs';
import { ReadTarball, UploadTarball } from '@verdaccio/streams';
import { Logger, RemoteUser } from '@verdaccio/types';
declare global {
@ -10,7 +13,4 @@ declare global {
}
}
declare module '@verdaccio/types' {
export type PackageAccessYaml = any;
export type FlagsConfig = any;
}
export interface StoragePluginLegacy<T> extends pluginUtils.Storage<T> {}

149
yarn.lock
View file

@ -2982,6 +2982,21 @@ __metadata:
languageName: node
linkType: hard
"@verdaccio/config@npm:6.0.0-6-next.67":
version: 6.0.0-6-next.67
resolution: "@verdaccio/config@npm:6.0.0-6-next.67"
dependencies:
"@verdaccio/core": 6.0.0-6-next.67
"@verdaccio/utils": 6.0.0-6-next.35
debug: 4.3.4
js-yaml: 4.1.0
lodash: 4.17.21
minimatch: 3.1.2
yup: 0.32.11
checksum: 822fd5d63db99a3b5f25ee80337878d7118438c329fa7bf9586dbf4ccf987873b0833ab7edbacfe311aa31cf4b8c2d4cbe2f55509057b49141992011b301bc0a
languageName: node
linkType: hard
"@verdaccio/core@npm:6.0.0-6-next.66":
version: 6.0.0-6-next.66
resolution: "@verdaccio/core@npm:6.0.0-6-next.66"
@ -2996,6 +3011,20 @@ __metadata:
languageName: node
linkType: hard
"@verdaccio/core@npm:6.0.0-6-next.67":
version: 6.0.0-6-next.67
resolution: "@verdaccio/core@npm:6.0.0-6-next.67"
dependencies:
ajv: 8.11.2
core-js: 3.28.0
http-errors: 1.8.1
http-status-codes: 2.2.0
process-warning: 1.0.0
semver: 7.3.8
checksum: c039318870bb5baf04ce637728afb1c41021f48088c4639945054e6c91b1caea1819800caf74c32015e00f32a9febaaa78ba89cc0a6efdd0b148a2068112016c
languageName: node
linkType: hard
"@verdaccio/file-locking@npm:10.3.0":
version: 10.3.0
resolution: "@verdaccio/file-locking@npm:10.3.0"
@ -3021,25 +3050,25 @@ __metadata:
languageName: node
linkType: hard
"@verdaccio/logger-7@npm:6.0.0-6-next.11":
version: 6.0.0-6-next.11
resolution: "@verdaccio/logger-7@npm:6.0.0-6-next.11"
"@verdaccio/logger-7@npm:6.0.0-6-next.12":
version: 6.0.0-6-next.12
resolution: "@verdaccio/logger-7@npm:6.0.0-6-next.12"
dependencies:
"@verdaccio/logger-commons": 6.0.0-6-next.34
"@verdaccio/logger-commons": 6.0.0-6-next.35
pino: 7.11.0
checksum: 755f7f3a6122dc8f47ca72015b438bb9b1830c044a7e03d9eebd199af3c551c2903646bbc4bdfe75d7e30baf200866dea454f1bad3cd5899c032d033d9d0b4d7
checksum: 3585b19083cda2658a74928d0fa892d1c1ff4b340af6fe19945914aec66a455738b51d246d41834e53eaaa54cb5302684b2e4be528f9e774cdb95410715a202c
languageName: node
linkType: hard
"@verdaccio/logger-commons@npm:6.0.0-6-next.34":
version: 6.0.0-6-next.34
resolution: "@verdaccio/logger-commons@npm:6.0.0-6-next.34"
"@verdaccio/logger-commons@npm:6.0.0-6-next.35":
version: 6.0.0-6-next.35
resolution: "@verdaccio/logger-commons@npm:6.0.0-6-next.35"
dependencies:
"@verdaccio/core": 6.0.0-6-next.66
"@verdaccio/core": 6.0.0-6-next.67
"@verdaccio/logger-prettify": 6.0.0-6-next.9
colorette: 2.0.19
debug: 4.3.4
checksum: 6bcb5fa99bb8b2c618b61fc5908654c5122cd6a57101e0c6257e48c0ec0011280e2268c41a413f3eb6cdc0683366834281231ec7e8f6dd739bf3fb1f6663bc36
checksum: 1726111f2b16d48ef45593fe329c3c235ad5cc872c954c07a446746d9ff25bff4822e5173605d76aa6857fee1daf119f32be175eef7f6556e7fe4aabf1d3ce63
languageName: node
linkType: hard
@ -3056,21 +3085,21 @@ __metadata:
languageName: node
linkType: hard
"@verdaccio/middleware@npm:6.0.0-6-next.45":
version: 6.0.0-6-next.45
resolution: "@verdaccio/middleware@npm:6.0.0-6-next.45"
"@verdaccio/middleware@npm:6.0.0-6-next.46":
version: 6.0.0-6-next.46
resolution: "@verdaccio/middleware@npm:6.0.0-6-next.46"
dependencies:
"@verdaccio/config": 6.0.0-6-next.66
"@verdaccio/core": 6.0.0-6-next.66
"@verdaccio/url": 11.0.0-6-next.32
"@verdaccio/utils": 6.0.0-6-next.34
"@verdaccio/config": 6.0.0-6-next.67
"@verdaccio/core": 6.0.0-6-next.67
"@verdaccio/url": 11.0.0-6-next.33
"@verdaccio/utils": 6.0.0-6-next.35
debug: 4.3.4
express: 4.18.2
express-rate-limit: 5.5.1
lodash: 4.17.21
lru-cache: 7.16.1
mime: 2.6.0
checksum: d3be4aae54cea1ee9c7eae6965797262db2e920822b70baaaee1702130d5f03848c091038ea8b82e17cde69c775dd12bcd11f383b793bcc20fb366c5d50a2ecf
checksum: a53154f3b5d6f393d07bb569cd6a03c0c19df5d703e82151f0cc3a600fea5cd3d5d1d72df49b75ffa7bd73b82b6d8f46ff30d04aaaf4b26ba5f174db5e3d8f55
languageName: node
linkType: hard
@ -3092,42 +3121,42 @@ __metadata:
languageName: node
linkType: hard
"@verdaccio/tarball@npm:11.0.0-6-next.35":
version: 11.0.0-6-next.35
resolution: "@verdaccio/tarball@npm:11.0.0-6-next.35"
"@verdaccio/tarball@npm:11.0.0-6-next.36":
version: 11.0.0-6-next.36
resolution: "@verdaccio/tarball@npm:11.0.0-6-next.36"
dependencies:
"@verdaccio/core": 6.0.0-6-next.66
"@verdaccio/url": 11.0.0-6-next.32
"@verdaccio/utils": 6.0.0-6-next.34
"@verdaccio/core": 6.0.0-6-next.67
"@verdaccio/url": 11.0.0-6-next.33
"@verdaccio/utils": 6.0.0-6-next.35
debug: 4.3.4
lodash: 4.17.21
checksum: 6ab29b067c9d531659fded5b689f331bc87b669a28637bc8f5ce632def2804d5fbff9521ee30e071d7901f49f09949b8341dd3330ec470193f36abcae1047c73
checksum: 857d74fbb1cc0a4f0a4ae691dfeefb57a99fe023817487a266bbc53dde151bf7a618813b555e284cbee88df7caa80d3d186f0a9e8b2f60864dc31e523b73d99d
languageName: node
linkType: hard
"@verdaccio/types@npm:10.7.1":
version: 10.7.1
resolution: "@verdaccio/types@npm:10.7.1"
checksum: 086ef79ef1cff075b1a3444c048ca11694b53b3fc9b69000e496b9c5c3dceb32f4016c939125a7fbb5eaa72797acf9ec8edfe09f8d480e0cf6ee046c5dd7ce36
"@verdaccio/types@npm:11.0.0-6-next.25":
version: 11.0.0-6-next.25
resolution: "@verdaccio/types@npm:11.0.0-6-next.25"
checksum: 5e5628b2703ffb501b31abc53c1d1b02c2fb7ad6daa4ce07ce2869590376551b5e1aacebddb524a886e55e94915bdb2f14e872e8cf4631793c0dab1f702ab91a
languageName: node
linkType: hard
"@verdaccio/ui-theme@npm:6.0.0-6-next.66":
version: 6.0.0-6-next.66
resolution: "@verdaccio/ui-theme@npm:6.0.0-6-next.66"
checksum: d255ef2e192f9ce94800a0f3ee31c41b8c07a6b9cd4cd537be587b753e147002de099c51abc55fae50ec0d263b9ffceb524877c2a46b7938d036ea8bd60171ec
"@verdaccio/ui-theme@npm:6.0.0-6-next.67":
version: 6.0.0-6-next.67
resolution: "@verdaccio/ui-theme@npm:6.0.0-6-next.67"
checksum: 5e6a8deca79ffe044f3dac76bc381f781e0c790ede9a069861d3c017cdb78ae90b4e14472c5fc5acdb1b573c3b5a398d82fb36cd48747d29b0c5d81806ef95ee
languageName: node
linkType: hard
"@verdaccio/url@npm:11.0.0-6-next.32":
version: 11.0.0-6-next.32
resolution: "@verdaccio/url@npm:11.0.0-6-next.32"
"@verdaccio/url@npm:11.0.0-6-next.33":
version: 11.0.0-6-next.33
resolution: "@verdaccio/url@npm:11.0.0-6-next.33"
dependencies:
"@verdaccio/core": 6.0.0-6-next.66
"@verdaccio/core": 6.0.0-6-next.67
debug: 4.3.4
lodash: 4.17.21
validator: 13.9.0
checksum: 93ac44ed594b07d68bde56da1502ca4e48e30cc90a2e1bdd9857a8f00121ed347549ba96c125b4476a462466237e2d1b012865a5027d13d133eb1bb5231a6215
checksum: e138638e0f0a479133135199d8db91d45295854366132ae514266c67c8169171bd5b5a251a4629f41b8ae3dae1f295190ff89557d49e6029ff09026312268eb8
languageName: node
linkType: hard
@ -3143,6 +3172,18 @@ __metadata:
languageName: node
linkType: hard
"@verdaccio/utils@npm:6.0.0-6-next.35":
version: 6.0.0-6-next.35
resolution: "@verdaccio/utils@npm:6.0.0-6-next.35"
dependencies:
"@verdaccio/core": 6.0.0-6-next.67
lodash: 4.17.21
minimatch: 3.1.2
semver: 7.3.8
checksum: 97f04effafb1627f85036e1fe4c626bfc42c0a58b44942d5f8578c6e2cf9d6b6d933d29b817aa5d7c6864901a438eb523c9744f3b7d1d2f5eef2765b6cbbfb1d
languageName: node
linkType: hard
"@yarnpkg/parsers@npm:^3.0.0-rc.32":
version: 3.0.0-rc.38
resolution: "@yarnpkg/parsers@npm:3.0.0-rc.38"
@ -10589,16 +10630,16 @@ __metadata:
languageName: node
linkType: hard
"verdaccio-audit@npm:11.0.0-6-next.29":
version: 11.0.0-6-next.29
resolution: "verdaccio-audit@npm:11.0.0-6-next.29"
"verdaccio-audit@npm:11.0.0-6-next.30":
version: 11.0.0-6-next.30
resolution: "verdaccio-audit@npm:11.0.0-6-next.30"
dependencies:
"@verdaccio/config": 6.0.0-6-next.66
"@verdaccio/core": 6.0.0-6-next.66
"@verdaccio/config": 6.0.0-6-next.67
"@verdaccio/core": 6.0.0-6-next.67
express: 4.18.2
https-proxy-agent: 5.0.1
node-fetch: cjs
checksum: 746f0e3e3701c98864e3c2399f28a612abcaa7b387c7814bb98d698d7215fa545b5a556b9eb040d8155e54101cf118ccab9de010ad87b3b62363ffb8b1a64e4b
checksum: 3cfd734653d3d89055d9171e95b4b18e7c6d572bd0cbc88bfe17eeb4bdb419d49cfee48f12d7c52dbabd8ff5639e5462c46cc8ef4c46adbd084fc292dd0e595c
languageName: node
linkType: hard
@ -10680,17 +10721,17 @@ __metadata:
"@typescript-eslint/parser": 5.49.0
"@verdaccio-scope/verdaccio-auth-foo": 0.0.2
"@verdaccio/config": 6.0.0-6-next.66
"@verdaccio/core": 6.0.0-6-next.66
"@verdaccio/core": 6.0.0-6-next.67
"@verdaccio/local-storage": 10.3.1
"@verdaccio/logger-7": 6.0.0-6-next.11
"@verdaccio/middleware": 6.0.0-6-next.45
"@verdaccio/logger-7": 6.0.0-6-next.12
"@verdaccio/middleware": 6.0.0-6-next.46
"@verdaccio/signature": 6.0.0-6-next.2
"@verdaccio/streams": 10.2.0
"@verdaccio/tarball": 11.0.0-6-next.35
"@verdaccio/types": 10.7.1
"@verdaccio/ui-theme": 6.0.0-6-next.66
"@verdaccio/url": 11.0.0-6-next.32
"@verdaccio/utils": 6.0.0-6-next.34
"@verdaccio/tarball": 11.0.0-6-next.36
"@verdaccio/types": 11.0.0-6-next.25
"@verdaccio/ui-theme": 6.0.0-6-next.67
"@verdaccio/url": 11.0.0-6-next.33
"@verdaccio/utils": 6.0.0-6-next.35
JSONStream: 1.3.5
async: 3.2.4
babel-eslint: 10.1.0
@ -10748,12 +10789,12 @@ __metadata:
ts-node: 10.9.1
typescript: 4.9.5
validator: 13.9.0
verdaccio-audit: 11.0.0-6-next.29
verdaccio-audit: 11.0.0-6-next.30
verdaccio-auth-memory: 10.2.0
verdaccio-htpasswd: 10.5.2
verdaccio-memory: 10.3.0
dependenciesMeta:
"@verdaccio/logger-7@6.0.0-6-next.7":
"@verdaccio/types@11.0.0-6-next.24":
unplugged: true
bin:
verdaccio: ./bin/verdaccio