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

feat: improved config and token signature (#3658)

* chore: add signature module

* feat: improved config and token signature

feat: improved config and token signature

Update package.json

* chore: update deps

* types

* fix: logger missing options

* chore: update deps

* update dep

* Update e2e-jest-workflow.yml

* Update init.ts

* Update config-path.ts

* fix logger

* Update init.ts
This commit is contained in:
Juan Picado 2023-03-03 21:32:10 +01:00 committed by GitHub
parent 8c8dafc8a0
commit e50d4d92a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 217 additions and 768 deletions

View file

@ -206,7 +206,7 @@ jobs:
echo "const leftPad = require('left-pad'); it('should resolve a module', () => { expect(typeof leftPad).toBe('function');});" | tee module.test.js
yarn jest module.test.js
pnpm7:
name: 'pnpm:next-7:jest example'
name: 'pnpm:7:jest example'
runs-on: ubuntu-latest
steps:
@ -217,12 +217,12 @@ jobs:
with:
node-version: 16.x
- name: 'install latest pnpm'
run: npm i -g pnpm@next-7
run: npm i -g pnpm@latest-7
- name: Install Dependencies
run: yarn install
- name: 'Run verdaccio in the background'
run: |
nohup yarn node ./scripts/run-verdaccio.js &
yarn node ./scripts/run-verdaccio.js &
- name: 'Ping to verdaccio'
run: |
pnpm ping --registry http://localhost:4873

210
.pnp.cjs generated
View file

@ -68,17 +68,18 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@typescript-eslint/eslint-plugin", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.49.0"],\
["@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.62"],\
["@verdaccio/core", "npm:6.0.0-6-next.62"],\
["@verdaccio/config", "npm:6.0.0-6-next.63"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["@verdaccio/local-storage", "npm:10.3.1"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.7"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.41"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.8"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.42"],\
["@verdaccio/signature", "npm:6.0.0-6-next.2"],\
["@verdaccio/streams", "npm:10.2.0"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.31"],\
["@verdaccio/types", "npm:10.7.0"],\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.62"],\
["@verdaccio/url", "npm:11.0.0-6-next.28"],\
["@verdaccio/utils", "npm:6.0.0-6-next.30"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.32"],\
["@verdaccio/types", "npm:10.7.1"],\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.63"],\
["@verdaccio/url", "npm:11.0.0-6-next.29"],\
["@verdaccio/utils", "npm:6.0.0-6-next.31"],\
["JSONStream", "npm:1.3.5"],\
["async", "npm:3.2.4"],\
["babel-eslint", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.1.0"],\
@ -138,7 +139,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["ts-node", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.9.1"],\
["typescript", "patch:typescript@npm%3A4.1.3#~builtin<compat/typescript>::version=4.1.3&hash=4a8eb8"],\
["validator", "npm:13.9.0"],\
["verdaccio-audit", "npm:11.0.0-6-next.23"],\
["verdaccio-audit", "npm:11.0.0-6-next.26"],\
["verdaccio-auth-memory", "npm:10.2.0"],\
["verdaccio-htpasswd", "npm:10.5.2"],\
["verdaccio-memory", "npm:10.3.0"]\
@ -5021,26 +5022,12 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/config", [\
["npm:6.0.0-6-next.60", {\
"packageLocation": "./.yarn/cache/@verdaccio-config-npm-6.0.0-6-next.60-f4e4316ecc-93e7e22a65.zip/node_modules/@verdaccio/config/",\
["npm:6.0.0-6-next.63", {\
"packageLocation": "./.yarn/cache/@verdaccio-config-npm-6.0.0-6-next.63-d9081a2c96-e570992530.zip/node_modules/@verdaccio/config/",\
"packageDependencies": [\
["@verdaccio/config", "npm:6.0.0-6-next.60"],\
["@verdaccio/core", "npm:6.0.0-6-next.60"],\
["@verdaccio/utils", "npm:6.0.0-6-next.28"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["lodash", "npm:4.17.21"],\
["minimatch", "npm:3.1.2"],\
["yaml", "npm:2.2.0"],\
["yup", "npm:0.32.11"]\
],\
"linkType": "HARD"\
}],\
["npm:6.0.0-6-next.62", {\
"packageLocation": "./.yarn/cache/@verdaccio-config-npm-6.0.0-6-next.62-fc647d6480-a1ec4bbe51.zip/node_modules/@verdaccio/config/",\
"packageDependencies": [\
["@verdaccio/config", "npm:6.0.0-6-next.62"],\
["@verdaccio/core", "npm:6.0.0-6-next.62"],\
["@verdaccio/utils", "npm:6.0.0-6-next.30"],\
["@verdaccio/config", "npm:6.0.0-6-next.63"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["@verdaccio/utils", "npm:6.0.0-6-next.31"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["js-yaml", "npm:4.1.0"],\
["lodash", "npm:4.17.21"],\
@ -5051,23 +5038,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/core", [\
["npm:6.0.0-6-next.60", {\
"packageLocation": "./.yarn/cache/@verdaccio-core-npm-6.0.0-6-next.60-2d2b64aa8a-059d6e906c.zip/node_modules/@verdaccio/core/",\
["npm:6.0.0-6-next.63", {\
"packageLocation": "./.yarn/cache/@verdaccio-core-npm-6.0.0-6-next.63-2e4bd5002d-5482de0363.zip/node_modules/@verdaccio/core/",\
"packageDependencies": [\
["@verdaccio/core", "npm:6.0.0-6-next.60"],\
["ajv", "npm:8.11.2"],\
["core-js", "npm:3.27.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"\
}],\
["npm:6.0.0-6-next.62", {\
"packageLocation": "./.yarn/cache/@verdaccio-core-npm-6.0.0-6-next.62-8bb88ecdeb-628c35522e.zip/node_modules/@verdaccio/core/",\
"packageDependencies": [\
["@verdaccio/core", "npm:6.0.0-6-next.62"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["ajv", "npm:8.11.2"],\
["core-js", "npm:3.28.0"],\
["http-errors", "npm:1.8.1"],\
@ -5106,22 +5080,22 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/logger-7", [\
["npm:6.0.0-6-next.7", {\
"packageLocation": "./.yarn/cache/@verdaccio-logger-7-npm-6.0.0-6-next.7-dc72fe3cd6-9fea77a8af.zip/node_modules/@verdaccio/logger-7/",\
["npm:6.0.0-6-next.8", {\
"packageLocation": "./.yarn/cache/@verdaccio-logger-7-npm-6.0.0-6-next.8-e3eb29a637-dad4916287.zip/node_modules/@verdaccio/logger-7/",\
"packageDependencies": [\
["@verdaccio/logger-7", "npm:6.0.0-6-next.7"],\
["@verdaccio/logger-commons", "npm:6.0.0-6-next.30"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.8"],\
["@verdaccio/logger-commons", "npm:6.0.0-6-next.31"],\
["pino", "npm:7.11.0"]\
],\
"linkType": "HARD"\
}]\
]],\
["@verdaccio/logger-commons", [\
["npm:6.0.0-6-next.30", {\
"packageLocation": "./.yarn/cache/@verdaccio-logger-commons-npm-6.0.0-6-next.30-a6fa1d55b3-b8593c1807.zip/node_modules/@verdaccio/logger-commons/",\
["npm:6.0.0-6-next.31", {\
"packageLocation": "./.yarn/cache/@verdaccio-logger-commons-npm-6.0.0-6-next.31-d40fe77eab-e2a9276d7f.zip/node_modules/@verdaccio/logger-commons/",\
"packageDependencies": [\
["@verdaccio/logger-commons", "npm:6.0.0-6-next.30"],\
["@verdaccio/core", "npm:6.0.0-6-next.62"],\
["@verdaccio/logger-commons", "npm:6.0.0-6-next.31"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["@verdaccio/logger-prettify", "npm:6.0.0-6-next.9"],\
["colorette", "npm:2.0.19"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"]\
@ -5144,14 +5118,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/middleware", [\
["npm:6.0.0-6-next.41", {\
"packageLocation": "./.yarn/cache/@verdaccio-middleware-npm-6.0.0-6-next.41-12c04e10d7-ea2b10eba5.zip/node_modules/@verdaccio/middleware/",\
["npm:6.0.0-6-next.42", {\
"packageLocation": "./.yarn/cache/@verdaccio-middleware-npm-6.0.0-6-next.42-b919b3b771-6ee70fa2bb.zip/node_modules/@verdaccio/middleware/",\
"packageDependencies": [\
["@verdaccio/middleware", "npm:6.0.0-6-next.41"],\
["@verdaccio/config", "npm:6.0.0-6-next.62"],\
["@verdaccio/core", "npm:6.0.0-6-next.62"],\
["@verdaccio/url", "npm:11.0.0-6-next.28"],\
["@verdaccio/utils", "npm:6.0.0-6-next.30"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.42"],\
["@verdaccio/config", "npm:6.0.0-6-next.63"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["@verdaccio/url", "npm:11.0.0-6-next.29"],\
["@verdaccio/utils", "npm:6.0.0-6-next.31"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["express", "npm:4.18.2"],\
["express-rate-limit", "npm:5.5.1"],\
@ -5162,6 +5136,18 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
"linkType": "HARD"\
}]\
]],\
["@verdaccio/signature", [\
["npm:6.0.0-6-next.2", {\
"packageLocation": "./.yarn/cache/@verdaccio-signature-npm-6.0.0-6-next.2-84876e53f2-6e5331ee23.zip/node_modules/@verdaccio/signature/",\
"packageDependencies": [\
["@verdaccio/signature", "npm:6.0.0-6-next.2"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["jsonwebtoken", "npm:9.0.0"],\
["lodash", "npm:4.17.21"]\
],\
"linkType": "HARD"\
}]\
]],\
["@verdaccio/streams", [\
["npm:10.2.0", {\
"packageLocation": "./.yarn/cache/@verdaccio-streams-npm-10.2.0-81db112291-2c5fd4953f.zip/node_modules/@verdaccio/streams/",\
@ -5172,13 +5158,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/tarball", [\
["npm:11.0.0-6-next.31", {\
"packageLocation": "./.yarn/cache/@verdaccio-tarball-npm-11.0.0-6-next.31-a5745d9f4d-f4f8006c6a.zip/node_modules/@verdaccio/tarball/",\
["npm:11.0.0-6-next.32", {\
"packageLocation": "./.yarn/cache/@verdaccio-tarball-npm-11.0.0-6-next.32-0e4e9c55a3-6d99a03e8e.zip/node_modules/@verdaccio/tarball/",\
"packageDependencies": [\
["@verdaccio/tarball", "npm:11.0.0-6-next.31"],\
["@verdaccio/core", "npm:6.0.0-6-next.62"],\
["@verdaccio/url", "npm:11.0.0-6-next.28"],\
["@verdaccio/utils", "npm:6.0.0-6-next.30"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.32"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["@verdaccio/url", "npm:11.0.0-6-next.29"],\
["@verdaccio/utils", "npm:6.0.0-6-next.31"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["lodash", "npm:4.17.21"]\
],\
@ -5186,29 +5172,29 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/types", [\
["npm:10.7.0", {\
"packageLocation": "./.yarn/cache/@verdaccio-types-npm-10.7.0-28c6045ab8-1439a0f6df.zip/node_modules/@verdaccio/types/",\
["npm:10.7.1", {\
"packageLocation": "./.yarn/cache/@verdaccio-types-npm-10.7.1-3c42d169da-086ef79ef1.zip/node_modules/@verdaccio/types/",\
"packageDependencies": [\
["@verdaccio/types", "npm:10.7.0"]\
["@verdaccio/types", "npm:10.7.1"]\
],\
"linkType": "HARD"\
}]\
]],\
["@verdaccio/ui-theme", [\
["npm:6.0.0-6-next.62", {\
"packageLocation": "./.yarn/cache/@verdaccio-ui-theme-npm-6.0.0-6-next.62-99b4445697-1a404d0f1d.zip/node_modules/@verdaccio/ui-theme/",\
["npm:6.0.0-6-next.63", {\
"packageLocation": "./.yarn/cache/@verdaccio-ui-theme-npm-6.0.0-6-next.63-0be4db2b6b-f22d063917.zip/node_modules/@verdaccio/ui-theme/",\
"packageDependencies": [\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.62"]\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.63"]\
],\
"linkType": "HARD"\
}]\
]],\
["@verdaccio/url", [\
["npm:11.0.0-6-next.28", {\
"packageLocation": "./.yarn/cache/@verdaccio-url-npm-11.0.0-6-next.28-da47c91476-0d36abf9ec.zip/node_modules/@verdaccio/url/",\
["npm:11.0.0-6-next.29", {\
"packageLocation": "./.yarn/cache/@verdaccio-url-npm-11.0.0-6-next.29-aec2138405-9a8e33a242.zip/node_modules/@verdaccio/url/",\
"packageDependencies": [\
["@verdaccio/url", "npm:11.0.0-6-next.28"],\
["@verdaccio/core", "npm:6.0.0-6-next.62"],\
["@verdaccio/url", "npm:11.0.0-6-next.29"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["lodash", "npm:4.17.21"],\
["validator", "npm:13.9.0"]\
@ -5217,22 +5203,11 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/utils", [\
["npm:6.0.0-6-next.28", {\
"packageLocation": "./.yarn/cache/@verdaccio-utils-npm-6.0.0-6-next.28-c868bd3942-cea635e77c.zip/node_modules/@verdaccio/utils/",\
["npm:6.0.0-6-next.31", {\
"packageLocation": "./.yarn/cache/@verdaccio-utils-npm-6.0.0-6-next.31-999a173ba7-d6c849c845.zip/node_modules/@verdaccio/utils/",\
"packageDependencies": [\
["@verdaccio/utils", "npm:6.0.0-6-next.28"],\
["@verdaccio/core", "npm:6.0.0-6-next.60"],\
["lodash", "npm:4.17.21"],\
["minimatch", "npm:3.1.2"],\
["semver", "npm:7.3.8"]\
],\
"linkType": "HARD"\
}],\
["npm:6.0.0-6-next.30", {\
"packageLocation": "./.yarn/cache/@verdaccio-utils-npm-6.0.0-6-next.30-aa2bec63b0-aebc1d581b.zip/node_modules/@verdaccio/utils/",\
"packageDependencies": [\
["@verdaccio/utils", "npm:6.0.0-6-next.30"],\
["@verdaccio/core", "npm:6.0.0-6-next.62"],\
["@verdaccio/utils", "npm:6.0.0-6-next.31"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["lodash", "npm:4.17.21"],\
["minimatch", "npm:3.1.2"],\
["semver", "npm:7.3.8"]\
@ -6951,13 +6926,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
],\
"linkType": "HARD"\
}],\
["npm:3.27.0", {\
"packageLocation": "./.yarn/unplugged/core-js-npm-3.27.0-a4e072d590/node_modules/core-js/",\
"packageDependencies": [\
["core-js", "npm:3.27.0"]\
],\
"linkType": "HARD"\
}],\
["npm:3.27.2", {\
"packageLocation": "./.yarn/unplugged/core-js-npm-3.27.2-99146711a6/node_modules/core-js/",\
"packageDependencies": [\
@ -11499,10 +11467,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
],\
"linkType": "HARD"\
}],\
["virtual:3db624596952c54d0f43797faed029b18df0dd118eb6a3a2066ab16f59a3ad611e6d68074f022a94e833bcb6b0bb398b6cfd64ea470afea866b835f8060967c3#npm:2.6.7", {\
"packageLocation": "./.yarn/__virtual__/node-fetch-virtual-c106191fe7/0/cache/node-fetch-npm-2.6.7-777aa2a6df-8d816ffd1e.zip/node_modules/node-fetch/",\
["virtual:ba5481a20e14b5defa2f3db22489403a4de9f5b4645871e0be81fb7e8290e7bf5d80c3d6f6435f950cd1eeae681924df27f429454447130d590f84ee64a21788#npm:2.6.7", {\
"packageLocation": "./.yarn/__virtual__/node-fetch-virtual-53e851eaf1/0/cache/node-fetch-npm-2.6.7-777aa2a6df-8d816ffd1e.zip/node_modules/node-fetch/",\
"packageDependencies": [\
["node-fetch", "virtual:3db624596952c54d0f43797faed029b18df0dd118eb6a3a2066ab16f59a3ad611e6d68074f022a94e833bcb6b0bb398b6cfd64ea470afea866b835f8060967c3#npm:2.6.7"],\
["node-fetch", "virtual:ba5481a20e14b5defa2f3db22489403a4de9f5b4645871e0be81fb7e8290e7bf5d80c3d6f6435f950cd1eeae681924df27f429454447130d590f84ee64a21788#npm:2.6.7"],\
["@types/encoding", null],\
["encoding", null],\
["whatwg-url", "npm:5.0.0"]\
@ -14262,17 +14230,18 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@typescript-eslint/eslint-plugin", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.49.0"],\
["@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.62"],\
["@verdaccio/core", "npm:6.0.0-6-next.62"],\
["@verdaccio/config", "npm:6.0.0-6-next.63"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["@verdaccio/local-storage", "npm:10.3.1"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.7"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.41"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.8"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.42"],\
["@verdaccio/signature", "npm:6.0.0-6-next.2"],\
["@verdaccio/streams", "npm:10.2.0"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.31"],\
["@verdaccio/types", "npm:10.7.0"],\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.62"],\
["@verdaccio/url", "npm:11.0.0-6-next.28"],\
["@verdaccio/utils", "npm:6.0.0-6-next.30"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.32"],\
["@verdaccio/types", "npm:10.7.1"],\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.63"],\
["@verdaccio/url", "npm:11.0.0-6-next.29"],\
["@verdaccio/utils", "npm:6.0.0-6-next.31"],\
["JSONStream", "npm:1.3.5"],\
["async", "npm:3.2.4"],\
["babel-eslint", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.1.0"],\
@ -14332,7 +14301,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["ts-node", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.9.1"],\
["typescript", "patch:typescript@npm%3A4.1.3#~builtin<compat/typescript>::version=4.1.3&hash=4a8eb8"],\
["validator", "npm:13.9.0"],\
["verdaccio-audit", "npm:11.0.0-6-next.23"],\
["verdaccio-audit", "npm:11.0.0-6-next.26"],\
["verdaccio-auth-memory", "npm:10.2.0"],\
["verdaccio-htpasswd", "npm:10.5.2"],\
["verdaccio-memory", "npm:10.3.0"]\
@ -14341,15 +14310,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["verdaccio-audit", [\
["npm:11.0.0-6-next.23", {\
"packageLocation": "./.yarn/cache/verdaccio-audit-npm-11.0.0-6-next.23-3db6245969-3c07ee4aaf.zip/node_modules/verdaccio-audit/",\
["npm:11.0.0-6-next.26", {\
"packageLocation": "./.yarn/cache/verdaccio-audit-npm-11.0.0-6-next.26-ba5481a20e-426067a7a7.zip/node_modules/verdaccio-audit/",\
"packageDependencies": [\
["verdaccio-audit", "npm:11.0.0-6-next.23"],\
["@verdaccio/config", "npm:6.0.0-6-next.60"],\
["@verdaccio/core", "npm:6.0.0-6-next.60"],\
["verdaccio-audit", "npm:11.0.0-6-next.26"],\
["@verdaccio/config", "npm:6.0.0-6-next.63"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["express", "npm:4.18.2"],\
["https-proxy-agent", "npm:5.0.1"],\
["node-fetch", "virtual:3db624596952c54d0f43797faed029b18df0dd118eb6a3a2066ab16f59a3ad611e6d68074f022a94e833bcb6b0bb398b6cfd64ea470afea866b835f8060967c3#npm:2.6.7"]\
["node-fetch", "virtual:ba5481a20e14b5defa2f3db22489403a4de9f5b4645871e0be81fb7e8290e7bf5d80c3d6f6435f950cd1eeae681924df27f429454447130d590f84ee64a21788#npm:2.6.7"]\
],\
"linkType": "HARD"\
}]\
@ -14608,13 +14577,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["yaml", "npm:1.10.2"]\
],\
"linkType": "HARD"\
}],\
["npm:2.2.0", {\
"packageLocation": "./.yarn/cache/yaml-npm-2.2.0-98687baef3-6c89da40c3.zip/node_modules/yaml/",\
"packageDependencies": [\
["yaml", "npm:2.2.0"]\
],\
"linkType": "HARD"\
}]\
]],\
["yargs", [\

Binary file not shown.

View file

@ -19,16 +19,17 @@
"url": "https://opencollective.com/verdaccio"
},
"dependencies": {
"@verdaccio/config": "6.0.0-6-next.62",
"@verdaccio/core": "6.0.0-6-next.62",
"@verdaccio/config": "6.0.0-6-next.63",
"@verdaccio/core": "6.0.0-6-next.63",
"@verdaccio/local-storage": "10.3.1",
"@verdaccio/logger-7": "6.0.0-6-next.7",
"@verdaccio/middleware": "6.0.0-6-next.41",
"@verdaccio/logger-7": "6.0.0-6-next.8",
"@verdaccio/middleware": "6.0.0-6-next.42",
"@verdaccio/signature": "6.0.0-6-next.2",
"@verdaccio/streams": "10.2.0",
"@verdaccio/tarball": "11.0.0-6-next.31",
"@verdaccio/ui-theme": "6.0.0-6-next.62",
"@verdaccio/url": "11.0.0-6-next.28",
"@verdaccio/utils": "6.0.0-6-next.30",
"@verdaccio/tarball": "11.0.0-6-next.32",
"@verdaccio/ui-theme": "6.0.0-6-next.63",
"@verdaccio/url": "11.0.0-6-next.29",
"@verdaccio/utils": "6.0.0-6-next.31",
"JSONStream": "1.3.5",
"async": "3.2.4",
"body-parser": "1.20.2",
@ -55,7 +56,7 @@
"request": "2.88.2",
"semver": "7.3.8",
"validator": "13.9.0",
"verdaccio-audit": "11.0.0-6-next.23",
"verdaccio-audit": "11.0.0-6-next.26",
"verdaccio-htpasswd": "10.5.2"
},
"devDependencies": {
@ -99,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.0",
"@verdaccio/types": "10.7.1",
"babel-eslint": "10.1.0",
"babel-jest": "29.4.1",
"babel-plugin-dynamic-import-node": "2.3.3",
@ -191,5 +192,10 @@
"url": "https://opencollective.com/verdaccio",
"logo": "https://opencollective.com/verdaccio/logo.txt"
},
"packageManager": "yarn@3.3.1"
"packageManager": "yarn@3.3.1",
"dependenciesMeta": {
"@verdaccio/logger-7@6.0.0-6-next.7": {
"unplugged": true
}
}
}

View file

@ -136,8 +136,6 @@ function addPackageWebApi(storage: IStorageHandler, auth: IAuth, config: Config)
}
res.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_PLAIN);
const referer = req.get('Referer');
const pathname = referer ? new URL(referer).pathname : undefined;
next(parseReadme(info.name, info.readme));
},
});

View file

@ -1,6 +1,7 @@
import buildDebug from 'debug';
import _ from 'lodash';
import { aesDecryptDeprecated as aesDecrypt, verifyPayload } from '@verdaccio/signature';
import {
APITokenOptions,
Callback,
@ -29,7 +30,6 @@ import {
TOKEN_BASIC,
TOKEN_BEARER,
} from './constants';
import { aesDecrypt, verifyPayload } from './crypto-utils';
import { logger } from './logger';
import { ErrorCode, convertPayloadToBase64 } from './utils';
@ -156,12 +156,6 @@ const defaultApiTokenConf: APITokenOptions = {
legacy: true,
};
// we limit max 1000 request per 15 minutes on user endpoints
export const defaultUserRateLimiting = {
windowMs: 15 * 60 * 1000, // 15 minutes
max: 1000,
};
export const defaultSecurity: Security = {
web: defaultWebTokenOptions,
api: defaultApiTokenConf,

View file

@ -2,6 +2,7 @@ import buildDebug from 'debug';
import { NextFunction } from 'express';
import _ from 'lodash';
import { aesEncryptDeprecated as aesEncrypt, signPayload } from '@verdaccio/signature';
import {
AllowAccess,
AuthPluginPackage,
@ -31,7 +32,6 @@ import {
verifyJWTPayload,
} from './auth-utils';
import { API_ERROR, SUPPORT_ERRORS, TOKEN_BASIC, TOKEN_BEARER } from './constants';
import { aesEncrypt, signPayload } from './crypto-utils';
import { logger } from './logger';
import { ErrorCode, convertPayloadToBase64 } from './utils';

View file

@ -9,12 +9,11 @@ if (process.getuid && process.getuid() === 0) {
// eslint-disable-next-line import/order
const logger = require('./logger');
logger.setup(null, { logStart: false }); // default setup
require('./cli/cli');
process.on('uncaughtException', function (err) {
logger.logger.fatal(
logger?.logger?.fatal(
{
err: err,
},

View file

@ -53,7 +53,7 @@ export class InitCommand extends Command {
let configPathLocation;
try {
configPathLocation = findConfigFile(this.config as string);
const verdaccioConfiguration = parseConfigFile(configPathLocation);
const verdaccioConfiguration: ReturnType<any> = parseConfigFile(configPathLocation);
if (!verdaccioConfiguration.self_path) {
verdaccioConfiguration.self_path = path.resolve(configPathLocation);
}
@ -61,7 +61,6 @@ export class InitCommand extends Command {
verdaccioConfiguration.https = { enable: false };
}
logger.logger.warn({ file: configPathLocation }, 'config file - @{file}');
process.title =
(verdaccioConfiguration.web && verdaccioConfiguration.web.title) || 'verdaccio';
@ -73,11 +72,10 @@ export class InitCommand extends Command {
pkgName,
listenDefaultCallback
);
logger.logger.info({ file: configPathLocation }, 'config file - @{file}');
} catch (err) {
logger.logger.fatal(
{ file: configPathLocation, err: err },
'cannot open config file @{file}: @{!err.message}'
);
// eslint-disable-next-line no-console
console.error(`cannot open config file ${configPathLocation}: ${!err.message}`);
process.exit(1);
}
}

View file

@ -4,7 +4,6 @@ import _ from 'lodash';
import mkdirp from 'mkdirp';
import Path from 'path';
import { logger } from './logger';
import { fileExists, folderExists } from './utils';
const debug = buildDebug('verdaccio:config');
@ -63,7 +62,6 @@ function readDefaultConfig(): string {
function createConfigFolder(configLocation): void {
mkdirp.sync(Path.dirname(configLocation.path));
logger.info({ file: configLocation.path }, 'Creating default config file in @{file}');
}
function updateStorageLinks(configLocation, defaultConfig): string {

View file

@ -42,25 +42,6 @@ export function normalizeUserList(oldFormat: any, newFormat: any): any {
return _.flatten(result);
}
export function uplinkSanityCheck(
uplinks: UpLinksConfList,
users: any = BLACKLIST
): UpLinksConfList {
const newUplinks = _.clone(uplinks);
let newUsers = _.clone(users);
for (const uplink in newUplinks) {
if (Object.prototype.hasOwnProperty.call(newUplinks, uplink)) {
if (_.isNil(newUplinks[uplink].cache)) {
newUplinks[uplink].cache = true;
}
newUsers = sanityCheckNames(uplink, newUsers);
}
}
return newUplinks;
}
export function sanityCheckNames(item: string, users: any): any {
assert(
item !== 'all' &&
@ -77,20 +58,6 @@ export function sanityCheckNames(item: string, users: any): any {
return users;
}
export function sanityCheckUplinksProps(configUpLinks: UpLinksConfList): UpLinksConfList {
const uplinks = _.clone(configUpLinks);
for (const uplink in uplinks) {
if (Object.prototype.hasOwnProperty.call(uplinks, uplink)) {
assert(uplinks[uplink].url, 'CONFIG: no url for uplink: ' + uplink);
assert(_.isString(uplinks[uplink].url), 'CONFIG: wrong url format for uplink: ' + uplink);
uplinks[uplink].url = uplinks[uplink].url.replace(/\/$/, '');
}
}
return uplinks;
}
/**
* Check whether an uplink can proxy
*/

View file

@ -1,113 +1,12 @@
import assert from 'assert';
// import assert from 'assert';
import _ from 'lodash';
import { getUserAgent } from '@verdaccio/config';
import { Config as AppConfig, Logger, PackageList, RateLimit, Security } from '@verdaccio/types';
import { generateRandomHexString, getMatchedPackagesSpec } from '@verdaccio/utils';
import { Config as ConfigCore } from '@verdaccio/config';
import { MatchedPackage, StartUpConfig } from '../types';
import { defaultUserRateLimiting } from './auth-utils';
import { normalisePackageAccess, sanityCheckUplinksProps, uplinkSanityCheck } from './config-utils';
import { APP_ERROR } from './constants';
import { isObject } from './utils';
const LoggerApi = require('./logger');
const strategicConfigProps = ['uplinks', 'packages'];
const allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];
/**
* Coordinates the application configuration
*/
class Config implements AppConfig {
public logger: Logger;
// @ts-ignore
public user_agent: boolean | string;
// @ts-ignore
public secret: string;
public uplinks: any;
public packages: PackageList;
public users: any;
public userRateLimit: RateLimit;
public server_id: string;
public self_path: string;
public storage: string | void;
public plugins: string | void;
// @ts-ignore
public security: Security;
public constructor(config: StartUpConfig) {
const self = this;
this.logger = LoggerApi.logger;
this.self_path = config.self_path;
this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;
this.plugins = config.plugins;
for (const configProp in config) {
if (self[configProp] == null) {
self[configProp] = config[configProp];
}
}
if (config?.user_agent) {
this.user_agent = getUserAgent(config?.user_agent);
}
this.userRateLimit = { ...defaultUserRateLimiting, ...config?.userRateLimit };
// some weird shell scripts are valid yaml files parsed as string
assert(_.isObject(config), APP_ERROR.CONFIG_NOT_VALID);
// sanity check for strategic config properties
strategicConfigProps.forEach(function (x): void {
if (self[x] == null) {
self[x] = {};
}
assert(isObject(self[x]), `CONFIG: bad "${x}" value (object expected)`);
});
this.uplinks = sanityCheckUplinksProps(uplinkSanityCheck(this.uplinks));
if (_.isNil(this.users) === false) {
this.logger.warn(`[users]: property on configuration file
is not longer supported, property being ignored`);
}
this.packages = normalisePackageAccess(self.packages);
// loading these from ENV if aren't in config
allowedEnvConfig.forEach((envConf): void => {
if (!(envConf in self)) {
self[envConf] = process.env[envConf] || process.env[envConf.toUpperCase()];
}
});
// unique identifier of self server (or a cluster), used to avoid loops
// @ts-ignore
if (!this.server_id) {
this.server_id = generateRandomHexString(6);
}
}
/**
* Check for package spec
*/
public getMatchedPackagesSpec(pkgName: string): MatchedPackage {
return getMatchedPackagesSpec(pkgName, this.packages);
}
/**
* Store or create whether receive a secret key
*/
public checkSecretKey(secret: string): string {
if (_.isString(secret) && _.isEmpty(secret) === false) {
this.secret = secret;
return secret;
}
// it generates a secret key
// FUTURE: this might be an external secret key, perhaps within config file?
this.secret = generateRandomHexString(32);
return this.secret;
class Config extends ConfigCore {
public constructor(config: any) {
config.configPath = config.self_path;
super(config, { forceEnhancedLegacySignature: false });
}
}

View file

@ -1,53 +0,0 @@
import { Hash, createCipher, createDecipher, createHash, pseudoRandomBytes } from 'crypto';
import jwt from 'jsonwebtoken';
import { JWTSignOptions, RemoteUser } from '@verdaccio/types';
export const defaultAlgorithm = 'aes192';
export const defaultTarballHashAlgorithm = 'sha1';
export function aesEncrypt(buf: Buffer, secret: string): Buffer {
// deprecated (it will be migrated in Verdaccio 5), it is a breaking change
// https://nodejs.org/api/crypto.html#crypto_crypto_createcipher_algorithm_password_options
// https://www.grainger.xyz/changing-from-cipher-to-cipheriv/
const c = createCipher(defaultAlgorithm, secret);
const b1 = c.update(buf);
const b2 = c.final();
return Buffer.concat([b1, b2]);
}
export function aesDecrypt(buf: Buffer, secret: string): Buffer {
try {
// deprecated (it will be migrated in Verdaccio 5), it is a breaking change
// https://nodejs.org/api/crypto.html#crypto_crypto_createdecipher_algorithm_password_options
// https://www.grainger.xyz/changing-from-cipher-to-cipheriv/
const c = createDecipher(defaultAlgorithm, secret);
const b1 = c.update(buf);
const b2 = c.final();
return Buffer.concat([b1, b2]);
} catch (_) {
return Buffer.alloc(0);
}
}
export async function signPayload(
payload: RemoteUser,
secretOrPrivateKey: string,
options: JWTSignOptions
): Promise<string> {
return new Promise(function (resolve, reject): Promise<string> {
return jwt.sign(
payload,
secretOrPrivateKey,
{
notBefore: '1', // Make sure the time will not rollback :)
...options,
},
(error, token) => (error ? reject(error) : resolve(token))
);
});
}
export function verifyPayload(token: string, secretOrPrivateKey: string): RemoteUser {
return jwt.verify(token, secretOrPrivateKey);
}

View file

@ -52,10 +52,10 @@ export function displayExperimentsInfoBox(flags) {
* @param config
*/
export async function runServer(config?: string): Promise<any> {
let configurationParsed: ConfigRuntime;
let configurationParsed: ReturnType<any>;
if (config === undefined || typeof config === 'string') {
const configPathLocation = findConfigFile(config);
configurationParsed = parseConfigFile(configPathLocation) as ConfigRuntime;
configurationParsed = parseConfigFile(configPathLocation);
if (!configurationParsed.self_path) {
configurationParsed.self_path = path.resolve(configPathLocation);
}

View file

@ -7,6 +7,7 @@ import semver from 'semver';
import { URL } from 'url';
import validator from 'validator';
import { parseConfigFile } from '@verdaccio/config';
// eslint-disable-next-line max-len
import { errorUtils, validatioUtils } from '@verdaccio/core';
import { StringValue } from '@verdaccio/types';
@ -20,7 +21,6 @@ import {
import { AuthorAvatar } from '../types';
import {
APP_ERROR,
DEFAULT_DOMAIN,
DEFAULT_PORT,
DEFAULT_PROTOCOL,
@ -40,7 +40,6 @@ const {
getServiceUnavailable,
getUnauthorized,
} = errorUtils;
const debug = buildDebug('verdaccio');
const validProtocols = ['https', 'http'];
export function convertPayloadToBase64(payload: string): Buffer {
return Buffer.from(payload, 'base64');
@ -243,23 +242,6 @@ export const ErrorCode = {
getCode,
};
export function parseConfigFile(configPath: string): any {
try {
if (/\.ya?ml$/i.test(configPath)) {
return YAML.load(fs.readFileSync(configPath, 'utf-8'));
}
debug('yaml parsed');
return require(configPath);
} catch (e) {
debug('yaml parse failed');
if (e.code !== 'MODULE_NOT_FOUND') {
e.message = APP_ERROR.CONFIG_NOT_VALID;
}
throw new Error(e);
}
}
/**
* Check whether the path already exist.
* @param {String} path
@ -365,6 +347,7 @@ export function addGravatarSupport(pkgInfo: Package, online = true): AuthorAvata
* @return {String} converted html template
*/
// TODO: rename, does not parse anymore
export function parseReadme(packageName: string, readme: string): string | void {
if (_.isEmpty(readme) === false) {
return readme;
@ -492,4 +475,4 @@ export function hasLogin(config: Config) {
return _.isNil(config?.web?.login) || config?.web?.login === true;
}
export { buildTokenUtil as buildToken };
export { buildTokenUtil as buildToken, parseConfigFile };

View file

@ -29,14 +29,6 @@ import {
export type StringValue = verdaccio$StringValue;
export interface StartUpConfig {
storage: string;
plugins?: string;
self_path: string;
user_agent?: boolean;
userRateLimit?: RateLimit;
}
// legacy should be removed in long term
export interface LegacyPackageList {

View file

@ -1,11 +1,3 @@
// @flow
export function spliceURL(...args: string[]): string {
return Array.from(args)
.reduce((lastResult, current) => lastResult + current)
.replace(/([^:])(\/)+(.)/g, `$1/$3`);
}
/**
* Quality values, or q-values and q-factors, are used to describe the order
* of priority of values in a comma-separated list.

View file

@ -1,5 +1,6 @@
import _ from 'lodash';
import { aesDecryptDeprecated as aesDecrypt, verifyPayload } from '@verdaccio/signature';
import { Config, RemoteUser, Security } from '@verdaccio/types';
import { buildUserBuffer } from '@verdaccio/utils';
@ -13,7 +14,6 @@ import {
} from '../../../../src/lib/auth-utils';
import AppConfig from '../../../../src/lib/config';
import { CHARACTER_ENCODING, TOKEN_BEARER } from '../../../../src/lib/constants';
import { aesDecrypt, verifyPayload } from '../../../../src/lib/crypto-utils';
import { setup } from '../../../../src/lib/logger';
import { buildToken, convertPayloadToBase64, parseConfigFile } from '../../../../src/lib/utils';
import { IAuth } from '../../../types';

View file

@ -1,15 +0,0 @@
import { aesDecrypt, aesEncrypt } from '../../../../src/lib/crypto-utils';
import { convertPayloadToBase64 } from '../../../../src/lib/utils';
describe('test crypto utils', () => {
describe('default encryption', () => {
test('decrypt payload flow', () => {
const payload = 'juan';
const token = aesEncrypt(Buffer.from(payload), '12345').toString('base64');
const data = aesDecrypt(convertPayloadToBase64(token), '12345').toString('utf8');
expect(payload).toEqual(data);
});
});
});

View file

@ -43,7 +43,7 @@ describe('bootstrap modern', () => {
test('run server should fails with wrong path', async () => {
const configPath = join(__dirname, './this_does_not_exist.yaml');
await expect(runServer(configPath)).rejects.toThrow(
/Error: CONFIG: it does not look like a valid config file/
'config file does not exist or not reachable'
);
});
});

View file

@ -63,7 +63,10 @@ const checkDefaultConfPackages = (config) => {
expect(config.url_prefix).toBeUndefined();
expect(config.experiments).toBeUndefined();
expect(config.security).toBeUndefined();
expect(config.security).toEqual({
api: { legacy: true },
web: { sign: { expiresIn: '1h' }, verify: {} },
});
};
describe('Config file', () => {

View file

@ -1,15 +1,8 @@
import _ from 'lodash';
import path from 'path';
import {
hasProxyTo,
normalisePackageAccess,
sanityCheckUplinksProps,
uplinkSanityCheck,
} from '../../../../src/lib/config-utils';
import { PACKAGE_ACCESS, ROLES } from '../../../../src/lib/constants';
import { hasProxyTo, normalisePackageAccess } from '../../../../src/lib/config-utils';
import { parseConfigFile } from '../../../../src/lib/utils';
import { spliceURL } from '../../../../src/utils/string';
describe('Config Utilities', () => {
const parseConfigurationFile = (conf) => {
@ -19,167 +12,6 @@ describe('Config Utilities', () => {
return path.join(__dirname, `../../partials/config/${format}/${name}.${format}`);
};
describe('uplinkSanityCheck', () => {
test('should test basic conversion', () => {
const uplinks = uplinkSanityCheck(
parseConfigFile(parseConfigurationFile('uplink-basic')).uplinks
);
expect(Object.keys(uplinks)).toContain('server1');
expect(Object.keys(uplinks)).toContain('server2');
});
test('should throw error on blacklisted uplink name', () => {
const { uplinks } = parseConfigFile(parseConfigurationFile('uplink-wrong'));
expect(() => {
uplinkSanityCheck(uplinks);
}).toThrow('CONFIG: reserved uplink name: anonymous');
});
});
describe('sanityCheckUplinksProps', () => {
test('should fails if url prop is missing', () => {
const { uplinks } = parseConfigFile(parseConfigurationFile('uplink-wrong'));
expect(() => {
sanityCheckUplinksProps(uplinks);
}).toThrow('CONFIG: no url for uplink: none-url');
});
test('should bypass an empty uplink list', () => {
// @ts-ignore
expect(sanityCheckUplinksProps([])).toHaveLength(0);
});
});
describe('normalisePackageAccess', () => {
test('should test basic conversion', () => {
const { packages } = parseConfigFile(parseConfigurationFile('pkgs-basic'));
const access = normalisePackageAccess(packages);
expect(access).toBeDefined();
const scoped = access[`${PACKAGE_ACCESS.SCOPE}`];
const all = access[`${PACKAGE_ACCESS.ALL}`];
expect(scoped).toBeDefined();
expect(all).toBeDefined();
});
test('should define an empty publish array even if is not defined in packages', () => {
const { packages } = parseConfigFile(parseConfigurationFile('pkgs-basic-no-publish'));
const access = normalisePackageAccess(packages);
const scoped = access[`${PACKAGE_ACCESS.SCOPE}`];
const all = access[`${PACKAGE_ACCESS.ALL}`];
// publish must defined
expect(scoped.publish).toBeDefined();
expect(scoped.publish).toHaveLength(0);
expect(all.publish).toBeDefined();
expect(all.publish).toHaveLength(0);
});
test('should define an empty access array even if is not defined in packages', () => {
const { packages } = parseConfigFile(parseConfigurationFile('pkgs-basic-no-access'));
const access = normalisePackageAccess(packages);
const scoped = access[`${PACKAGE_ACCESS.SCOPE}`];
const all = access[`${PACKAGE_ACCESS.ALL}`];
// publish must defined
expect(scoped.access).toBeDefined();
expect(scoped.access).toHaveLength(0);
expect(all.access).toBeDefined();
expect(all.access).toHaveLength(0);
});
test('should define an empty proxy array even if is not defined in package', () => {
const { packages } = parseConfigFile(parseConfigurationFile('pkgs-basic-no-proxy'));
const access = normalisePackageAccess(packages);
const scoped = access[`${PACKAGE_ACCESS.SCOPE}`];
const all = access[`${PACKAGE_ACCESS.ALL}`];
// publish must defined
expect(scoped.proxy).toBeDefined();
expect(scoped.proxy).toHaveLength(0);
expect(all.proxy).toBeDefined();
expect(all.proxy).toHaveLength(0);
});
test('should test multi user group definition', () => {
const { packages } = parseConfigFile(parseConfigurationFile('pkgs-multi-group'));
const access = normalisePackageAccess(packages);
expect(access).toBeDefined();
const scoped = access[`${PACKAGE_ACCESS.SCOPE}`];
const all = access[`${PACKAGE_ACCESS.ALL}`];
expect(scoped).toBeDefined();
expect(scoped.access).toContain('$all');
expect(scoped.publish).toHaveLength(2);
expect(scoped.publish).toContain('admin');
expect(scoped.publish).toContain('superadmin');
expect(all).toBeDefined();
expect(all.access).toHaveLength(3);
expect(all.access).toContain('$all');
expect(all.publish).toHaveLength(1);
expect(all.publish).toContain('admin');
});
test('should normalize deprecated packages into the new ones (backward props compatible)', () => {
const { packages } = parseConfigFile(parseConfigurationFile('deprecated-pkgs-basic'));
const access = normalisePackageAccess(packages);
expect(access).toBeDefined();
const scoped = access[`${PACKAGE_ACCESS.SCOPE}`];
const all = access[`${PACKAGE_ACCESS.ALL}`];
const react = access['react-*'];
expect(react).toBeDefined();
expect(react.access).toBeDefined();
// Intended checks, Typescript should catch this, we test the runtime part
// @ts-ignore
expect(react.access[0]).toBe(ROLES.$ALL);
expect(react.publish).toBeDefined();
// @ts-ignore
expect(react.publish[0]).toBe('admin');
expect(react.proxy).toBeDefined();
// @ts-ignore
expect(react.proxy[0]).toBe('uplink2');
expect(react.storage).toBeDefined();
expect(react.storage).toBe('react-storage');
expect(scoped).toBeDefined();
expect(scoped.storage).not.toBeDefined();
expect(all).toBeDefined();
expect(all.access).toBeDefined();
expect(all.storage).not.toBeDefined();
expect(all.publish).toBeDefined();
expect(all.proxy).toBeDefined();
expect(all.allow_access).toBeUndefined();
expect(all.allow_publish).toBeUndefined();
expect(all.proxy_access).toBeUndefined();
});
test('should check not default packages access', () => {
const { packages } = parseConfigFile(parseConfigurationFile('pkgs-empty'));
const access = normalisePackageAccess(packages);
expect(access).toBeDefined();
const scoped = access[`${PACKAGE_ACCESS.SCOPE}`];
expect(scoped).toBeUndefined();
// ** should be added by default **
const all = access[`${PACKAGE_ACCESS.ALL}`];
expect(all).toBeDefined();
expect(all.access).toBeDefined();
expect(_.isArray(all.access)).toBeTruthy();
expect(all.publish).toBeDefined();
expect(_.isArray(all.publish)).toBeTruthy();
});
});
describe('hasProxyTo', () => {
test('should test basic config', () => {
const packages = normalisePackageAccess(
@ -234,58 +66,4 @@ describe('Config Utilities', () => {
expect(hasProxyTo('private', 'fake', packages)).toBeFalsy();
});
});
describe('spliceURL', () => {
test('should splice two strings and generate a url', () => {
const url: string = spliceURL('http://domain.com', '/-/static/logo.png');
expect(url).toMatch('http://domain.com/-/static/logo.png');
});
test('should splice a empty strings and generate a url', () => {
const url: string = spliceURL('', '/-/static/logo.png');
expect(url).toMatch('/-/static/logo.png');
});
});
describe('JSON', () => {
test('parse default.json', () => {
const config = parseConfigFile(parseConfigurationFile('default.json'));
expect(config.storage).toBeDefined();
});
test('parse invalid.json', () => {
expect(function () {
parseConfigFile(parseConfigurationFile('invalid.json'));
}).toThrow(/Error/);
});
test('parse not-exists.json', () => {
expect(function () {
parseConfigFile(parseConfigurationFile('not-exists.json'));
}).toThrow(/Error/);
});
});
describe('JavaScript', () => {
test('parse default.js', () => {
const config = parseConfigFile(parseConfigurationFile('default.js'));
expect(config.storage).toBeDefined();
});
test('parse invalid.js', () => {
expect(function () {
parseConfigFile(parseConfigurationFile('invalid.js'));
}).toThrow(/Error/);
});
test('parse not-exists.js', () => {
expect(function () {
parseConfigFile(parseConfigurationFile('not-exists.js'));
}).toThrow(/Error/);
});
});
});

View file

@ -10,7 +10,7 @@ import {
parseReadme,
sortByName,
} from '../../../../src/lib/utils';
import { getByQualityPriorityValue, spliceURL } from '../../../../src/utils/string';
import { getByQualityPriorityValue } from '../../../../src/utils/string';
setup([]);
@ -137,18 +137,6 @@ describe('Utilities', () => {
});
describe('String utilities', () => {
test('should splice two strings and generate a url', () => {
const url: string = spliceURL('http://domain.com', '/-/static/logo.png');
expect(url).toMatch('http://domain.com/-/static/logo.png');
});
test('should splice a empty strings and generate a url', () => {
const url: string = spliceURL('', '/-/static/logo.png');
expect(url).toMatch('/-/static/logo.png');
});
test('getByQualityPriorityValue', () => {
expect(getByQualityPriorityValue('')).toEqual('');
expect(getByQualityPriorityValue(null)).toEqual('');

View file

@ -2,7 +2,7 @@
import _ from 'lodash';
import path from 'path';
import {parseConfigFile} from '../../../../src/lib/utils';
import {parseConfigFile} from '@verdaccio/config';
/**
* Override the default.yaml configuration file with any new config provided.

208
yarn.lock
View file

@ -2967,53 +2967,24 @@ __metadata:
languageName: node
linkType: hard
"@verdaccio/config@npm:6.0.0-6-next.60":
version: 6.0.0-6-next.60
resolution: "@verdaccio/config@npm:6.0.0-6-next.60"
"@verdaccio/config@npm:6.0.0-6-next.63":
version: 6.0.0-6-next.63
resolution: "@verdaccio/config@npm:6.0.0-6-next.63"
dependencies:
"@verdaccio/core": 6.0.0-6-next.60
"@verdaccio/utils": 6.0.0-6-next.28
debug: 4.3.4
lodash: 4.17.21
minimatch: 3.1.2
yaml: 2.2.0
yup: 0.32.11
checksum: 93e7e22a65383a55376da87618d6280dfa2922f42dda17f1c4cf5e2f3f676358a45a7d20398d0e85b335800b7635ce488d10fbd6d3b5a15f03390d0f109953dc
languageName: node
linkType: hard
"@verdaccio/config@npm:6.0.0-6-next.62":
version: 6.0.0-6-next.62
resolution: "@verdaccio/config@npm:6.0.0-6-next.62"
dependencies:
"@verdaccio/core": 6.0.0-6-next.62
"@verdaccio/utils": 6.0.0-6-next.30
"@verdaccio/core": 6.0.0-6-next.63
"@verdaccio/utils": 6.0.0-6-next.31
debug: 4.3.4
js-yaml: 4.1.0
lodash: 4.17.21
minimatch: 3.1.2
yup: 0.32.11
checksum: a1ec4bbe51e49e19b83940acb5d3344e245441cc316cfe284ce685c004f390333e1fd94fb6410c4025d07e890fbfdac7cfa6d61e129fce7da76a858aec685d4f
checksum: e570992530a46947d162d5cad945c776794ab67f2ac3ae79cddb1724fedfc8a35584236708573b5eadc0df71bf1b7db7bf479e04266f6173ad3fc057b7a53a76
languageName: node
linkType: hard
"@verdaccio/core@npm:6.0.0-6-next.60":
version: 6.0.0-6-next.60
resolution: "@verdaccio/core@npm:6.0.0-6-next.60"
dependencies:
ajv: 8.11.2
core-js: 3.27.0
http-errors: 1.8.1
http-status-codes: 2.2.0
process-warning: 1.0.0
semver: 7.3.8
checksum: 059d6e906c78470b36f2fda368614e8c1f471b4853aa5a7461a1e067e9fcfa4e6b6dd10eb5bd7613cb2898cd1d10cc0a36d0d80e0dd54cf5fbc2d49c0000ae1f
languageName: node
linkType: hard
"@verdaccio/core@npm:6.0.0-6-next.62":
version: 6.0.0-6-next.62
resolution: "@verdaccio/core@npm:6.0.0-6-next.62"
"@verdaccio/core@npm:6.0.0-6-next.63":
version: 6.0.0-6-next.63
resolution: "@verdaccio/core@npm:6.0.0-6-next.63"
dependencies:
ajv: 8.11.2
core-js: 3.28.0
@ -3021,7 +2992,7 @@ __metadata:
http-status-codes: 2.2.0
process-warning: 1.0.0
semver: 7.3.8
checksum: 628c35522e48b57aa01b9fa4ee869da7d3c8b9ac43905fe783a44d6e9f49b85a2298ee153b947c759cbc237ed9aba350fab2dd6698e74ebff6b9740a949d5718
checksum: 5482de036357d58a94566395b63f79ba553ae64305fe40afef3b0a9df3530c3ab454108c9806adcb76197f9623948eeb8321cfb61be9715d47b6c28318fa345e
languageName: node
linkType: hard
@ -3050,25 +3021,25 @@ __metadata:
languageName: node
linkType: hard
"@verdaccio/logger-7@npm:6.0.0-6-next.7":
version: 6.0.0-6-next.7
resolution: "@verdaccio/logger-7@npm:6.0.0-6-next.7"
"@verdaccio/logger-7@npm:6.0.0-6-next.8":
version: 6.0.0-6-next.8
resolution: "@verdaccio/logger-7@npm:6.0.0-6-next.8"
dependencies:
"@verdaccio/logger-commons": 6.0.0-6-next.30
"@verdaccio/logger-commons": 6.0.0-6-next.31
pino: 7.11.0
checksum: 9fea77a8af0ecd04f6ef11564632dcc26376e078ceb7af98cc4caa0744fb040165997458c1aed460497fbb6cc2bec54e9e88d3b51c44622ef4ec428042bb09b3
checksum: dad491628781329aca70eebbecb4aee6dcc25b72f64876bc30479698fbc312a0fcfb5bef23626c03ceb920742cdbe1242829ec9bd534987de482a2dfb388bb63
languageName: node
linkType: hard
"@verdaccio/logger-commons@npm:6.0.0-6-next.30":
version: 6.0.0-6-next.30
resolution: "@verdaccio/logger-commons@npm:6.0.0-6-next.30"
"@verdaccio/logger-commons@npm:6.0.0-6-next.31":
version: 6.0.0-6-next.31
resolution: "@verdaccio/logger-commons@npm:6.0.0-6-next.31"
dependencies:
"@verdaccio/core": 6.0.0-6-next.62
"@verdaccio/core": 6.0.0-6-next.63
"@verdaccio/logger-prettify": 6.0.0-6-next.9
colorette: 2.0.19
debug: 4.3.4
checksum: b8593c180763d30c1df08c5f75cc3d9c60c99de8596774c432dc84f68b194a8cee4dde392f3dc5839c34e3e43c928c48526c36d7c68bb793a4770a59f84ffc73
checksum: e2a9276d7fb00cec93014df581bab3732f5d09ab8322ac43a5a79d281f9d8169be1233dc425934b3327fda72d3e5850bfe9b7107ee7772bdb22591cb7210b50d
languageName: node
linkType: hard
@ -3085,21 +3056,32 @@ __metadata:
languageName: node
linkType: hard
"@verdaccio/middleware@npm:6.0.0-6-next.41":
version: 6.0.0-6-next.41
resolution: "@verdaccio/middleware@npm:6.0.0-6-next.41"
"@verdaccio/middleware@npm:6.0.0-6-next.42":
version: 6.0.0-6-next.42
resolution: "@verdaccio/middleware@npm:6.0.0-6-next.42"
dependencies:
"@verdaccio/config": 6.0.0-6-next.62
"@verdaccio/core": 6.0.0-6-next.62
"@verdaccio/url": 11.0.0-6-next.28
"@verdaccio/utils": 6.0.0-6-next.30
"@verdaccio/config": 6.0.0-6-next.63
"@verdaccio/core": 6.0.0-6-next.63
"@verdaccio/url": 11.0.0-6-next.29
"@verdaccio/utils": 6.0.0-6-next.31
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: ea2b10eba5fc27004cd72626506a4fb3bed8ddfd4acc138b4bb8263c0d42b1c85f2841b7b406996a38025e2dc5e89bd206ccd47d616e6a6c43c86914ffa273ba
checksum: 6ee70fa2bb3972afa4f822a44e9d166241b2596ff4632d1665f105c2f5d7677e84bb8976b133407dc4a17f6d39a426849400a1f6b16d37df98443cb1bc97243b
languageName: node
linkType: hard
"@verdaccio/signature@npm:6.0.0-6-next.2":
version: 6.0.0-6-next.2
resolution: "@verdaccio/signature@npm:6.0.0-6-next.2"
dependencies:
debug: 4.3.4
jsonwebtoken: 9.0.0
lodash: 4.17.21
checksum: 6e5331ee231be43cf521596f9ee6d1c39d73f249822e5cbe0e83ac91b3a4849adf53c6e9b4566a674b4134ecd2706e6734a1344cc8fa8dbe82232642ee07f631
languageName: node
linkType: hard
@ -3110,66 +3092,54 @@ __metadata:
languageName: node
linkType: hard
"@verdaccio/tarball@npm:11.0.0-6-next.31":
version: 11.0.0-6-next.31
resolution: "@verdaccio/tarball@npm:11.0.0-6-next.31"
"@verdaccio/tarball@npm:11.0.0-6-next.32":
version: 11.0.0-6-next.32
resolution: "@verdaccio/tarball@npm:11.0.0-6-next.32"
dependencies:
"@verdaccio/core": 6.0.0-6-next.62
"@verdaccio/url": 11.0.0-6-next.28
"@verdaccio/utils": 6.0.0-6-next.30
"@verdaccio/core": 6.0.0-6-next.63
"@verdaccio/url": 11.0.0-6-next.29
"@verdaccio/utils": 6.0.0-6-next.31
debug: 4.3.4
lodash: 4.17.21
checksum: f4f8006c6ab9e92c582dd4a91ae2917878f4485bac99c2cf97e0178a0f0be1b479520c7b5bff62dc97f9857a03545175e64b7e77c86df3c5ecce162056494cb4
checksum: 6d99a03e8e059ceed85c371c416d592fbcada4a7422e47b02c71757f0ab41b1948797214aaf398fe878f9aa6b731f95aca1438cac642db06c6be51eb64173894
languageName: node
linkType: hard
"@verdaccio/types@npm:10.7.0":
version: 10.7.0
resolution: "@verdaccio/types@npm:10.7.0"
checksum: 1439a0f6df4c7194375926ee132dcac41a65b0a37d28268a4dc7db2263fe7d6419f690ae7ef109c5fd194b7c5477e75587e6770ffcae6e0ea23c195082a09ceb
"@verdaccio/types@npm:10.7.1":
version: 10.7.1
resolution: "@verdaccio/types@npm:10.7.1"
checksum: 086ef79ef1cff075b1a3444c048ca11694b53b3fc9b69000e496b9c5c3dceb32f4016c939125a7fbb5eaa72797acf9ec8edfe09f8d480e0cf6ee046c5dd7ce36
languageName: node
linkType: hard
"@verdaccio/ui-theme@npm:6.0.0-6-next.62":
version: 6.0.0-6-next.62
resolution: "@verdaccio/ui-theme@npm:6.0.0-6-next.62"
checksum: 1a404d0f1d9df941f5d907ee2fba03124b87f0d0d23a2976cf3fdd5dc859864352cbfb46961a3497f7f1eaa9cd51bcb22702c7524c0864dc23ca0a244a5a2380
"@verdaccio/ui-theme@npm:6.0.0-6-next.63":
version: 6.0.0-6-next.63
resolution: "@verdaccio/ui-theme@npm:6.0.0-6-next.63"
checksum: f22d063917aa25321380090939681342cc9f1b6fe8192fa663cd8f2ecfb3ee312d00b925ba91a5d423cb4a7980eb0ac684dda6902e144f1f976ea3225884c56d
languageName: node
linkType: hard
"@verdaccio/url@npm:11.0.0-6-next.28":
version: 11.0.0-6-next.28
resolution: "@verdaccio/url@npm:11.0.0-6-next.28"
"@verdaccio/url@npm:11.0.0-6-next.29":
version: 11.0.0-6-next.29
resolution: "@verdaccio/url@npm:11.0.0-6-next.29"
dependencies:
"@verdaccio/core": 6.0.0-6-next.62
"@verdaccio/core": 6.0.0-6-next.63
debug: 4.3.4
lodash: 4.17.21
validator: 13.9.0
checksum: 0d36abf9ec9284b2704a0f3345844aa6dc7abcefcbf1a08db15ab1f3395413f8460626f9d0c73ee721b0ac075135b252d0b34589493504b81a87d879a38d5cec
checksum: 9a8e33a24239d3bdf419593d5cb2521ad9031df6298233501395097b40834e34c2cf6371a21ee9d3a6121d5dfee9d75265e1f5bc9c8a1ea8c030dee43847e342
languageName: node
linkType: hard
"@verdaccio/utils@npm:6.0.0-6-next.28":
version: 6.0.0-6-next.28
resolution: "@verdaccio/utils@npm:6.0.0-6-next.28"
"@verdaccio/utils@npm:6.0.0-6-next.31":
version: 6.0.0-6-next.31
resolution: "@verdaccio/utils@npm:6.0.0-6-next.31"
dependencies:
"@verdaccio/core": 6.0.0-6-next.60
"@verdaccio/core": 6.0.0-6-next.63
lodash: 4.17.21
minimatch: 3.1.2
semver: 7.3.8
checksum: cea635e77c7083252c1fe512d7116d97b1e4d74385b4c294b441ffbcf222e5d4f3cbfd693004252de0fee58389d2c69cd8efa2cb81589a9e68d77c598d613bfc
languageName: node
linkType: hard
"@verdaccio/utils@npm:6.0.0-6-next.30":
version: 6.0.0-6-next.30
resolution: "@verdaccio/utils@npm:6.0.0-6-next.30"
dependencies:
"@verdaccio/core": 6.0.0-6-next.62
lodash: 4.17.21
minimatch: 3.1.2
semver: 7.3.8
checksum: aebc1d581b8f4e6916de0e989dd9b67d49d1a109466176b2c7b83abf1b5182b7ca6ee3b9de0500effe0bdc825097b7e0e57cf40dab839c63e164ba483784c615
checksum: d6c849c845680c273c175ec60fd460d0ba4c68be750cf1d1e39bec4f62ec4ee515284c7e823006adc6ed071a81bf4cfb79382c2ec5d9d37f90963363047bcedd
languageName: node
linkType: hard
@ -4565,13 +4535,6 @@ __metadata:
languageName: node
linkType: hard
"core-js@npm:3.27.0":
version: 3.27.0
resolution: "core-js@npm:3.27.0"
checksum: 14bf6772e1c73a1cb3848ff63cae8d8f28354195e95ff550f2c4a7ae04650987691e37d6c9fe73789ffd97055b024fc7df825c203965f9a9b9aa6fb9f26f8571
languageName: node
linkType: hard
"core-js@npm:3.28.0":
version: 3.28.0
resolution: "core-js@npm:3.28.0"
@ -10875,16 +10838,16 @@ __metadata:
languageName: node
linkType: hard
"verdaccio-audit@npm:11.0.0-6-next.23":
version: 11.0.0-6-next.23
resolution: "verdaccio-audit@npm:11.0.0-6-next.23"
"verdaccio-audit@npm:11.0.0-6-next.26":
version: 11.0.0-6-next.26
resolution: "verdaccio-audit@npm:11.0.0-6-next.26"
dependencies:
"@verdaccio/config": 6.0.0-6-next.60
"@verdaccio/core": 6.0.0-6-next.60
"@verdaccio/config": 6.0.0-6-next.63
"@verdaccio/core": 6.0.0-6-next.63
express: 4.18.2
https-proxy-agent: 5.0.1
node-fetch: cjs
checksum: 3c07ee4aaf596257ef71e3d84641fd8785a2848b07f6fd6124bd3ca1ab08eead61391c4cbd5f4b7bc5ef2717f26d1f553c9b85af36dc6786eb8309f4ed946274
checksum: 426067a7a7a6358158e7205b43b029163186f67db12341e9d1e6aa40f910fce1f64375eedf6976bc78799842171ea4bd7fcd934b5126041083710a690e5f59f7
languageName: node
linkType: hard
@ -10965,17 +10928,18 @@ __metadata:
"@typescript-eslint/eslint-plugin": 5.49.0
"@typescript-eslint/parser": 5.49.0
"@verdaccio-scope/verdaccio-auth-foo": 0.0.2
"@verdaccio/config": 6.0.0-6-next.62
"@verdaccio/core": 6.0.0-6-next.62
"@verdaccio/config": 6.0.0-6-next.63
"@verdaccio/core": 6.0.0-6-next.63
"@verdaccio/local-storage": 10.3.1
"@verdaccio/logger-7": 6.0.0-6-next.7
"@verdaccio/middleware": 6.0.0-6-next.41
"@verdaccio/logger-7": 6.0.0-6-next.8
"@verdaccio/middleware": 6.0.0-6-next.42
"@verdaccio/signature": 6.0.0-6-next.2
"@verdaccio/streams": 10.2.0
"@verdaccio/tarball": 11.0.0-6-next.31
"@verdaccio/types": 10.7.0
"@verdaccio/ui-theme": 6.0.0-6-next.62
"@verdaccio/url": 11.0.0-6-next.28
"@verdaccio/utils": 6.0.0-6-next.30
"@verdaccio/tarball": 11.0.0-6-next.32
"@verdaccio/types": 10.7.1
"@verdaccio/ui-theme": 6.0.0-6-next.63
"@verdaccio/url": 11.0.0-6-next.29
"@verdaccio/utils": 6.0.0-6-next.31
JSONStream: 1.3.5
async: 3.2.4
babel-eslint: 10.1.0
@ -11035,10 +10999,13 @@ __metadata:
ts-node: 10.9.1
typescript: 4.1.3
validator: 13.9.0
verdaccio-audit: 11.0.0-6-next.23
verdaccio-audit: 11.0.0-6-next.26
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":
unplugged: true
bin:
verdaccio: ./bin/verdaccio
languageName: unknown
@ -11237,13 +11204,6 @@ __metadata:
languageName: node
linkType: hard
"yaml@npm:2.2.0":
version: 2.2.0
resolution: "yaml@npm:2.2.0"
checksum: 6c89da40c3c553648595a476f23f7082c17e51b268ecce7ee0464302cbc1ffc20ba86f1b876688eb9c7d8f4b71dc28efbd7b3b86bf414a959ce5150831a9233f
languageName: node
linkType: hard
"yaml@npm:^1.10.0, yaml@npm:^1.7.2":
version: 1.10.2
resolution: "yaml@npm:1.10.2"