Compare commits
102 Commits
@verdaccio
...
@verdaccio
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa3d878286 | ||
|
|
20c9e43edc | ||
|
|
18dc5f1f2f | ||
|
|
b7d319c5be | ||
|
|
f86c31ed0e | ||
|
|
076f0f85e8 | ||
|
|
c2a1f4a73a | ||
|
|
41475949ba | ||
|
|
d390a66158 | ||
|
|
7041a4381e | ||
|
|
14d973c552 | ||
|
|
13310814da | ||
|
|
16458f801e | ||
|
|
1322ffc2c4 | ||
|
|
2091f268d3 | ||
|
|
28331ff07a | ||
|
|
1ad1214c5e | ||
|
|
cf4489abb1 | ||
|
|
d7bf5453b1 | ||
|
|
3184ed41d8 | ||
|
|
0525ebfda3 | ||
|
|
6c1eb021ba | ||
|
|
1016fc0ff1 | ||
|
|
30875acc70 | ||
|
|
3dc5b5045f | ||
|
|
0f21053e04 | ||
|
|
a264faba47 | ||
|
|
d7005e6029 | ||
|
|
36b5ecd2dc | ||
|
|
9c03e11cfa | ||
|
|
640b92667f | ||
|
|
8478bd97b8 | ||
|
|
3836595506 | ||
|
|
7bac933b81 | ||
|
|
5cb4e6dc2f | ||
|
|
57d26af661 | ||
|
|
497c640fc3 | ||
|
|
47415298c9 | ||
|
|
453bfadba0 | ||
|
|
a0ee7c102a | ||
|
|
785da5a5b3 | ||
|
|
ae08b22730 | ||
|
|
b81417d774 | ||
|
|
500b25015d | ||
|
|
71fb7d1223 | ||
|
|
162d64e053 | ||
|
|
5776015058 | ||
|
|
f345fefd99 | ||
|
|
f6ffddbb5b | ||
|
|
98fbff4e1d | ||
|
|
d1aa663553 | ||
|
|
7fc26bf026 | ||
|
|
255e41ffce | ||
|
|
9ae112e129 | ||
|
|
ed32c53af8 | ||
|
|
49dfeed37d | ||
|
|
b56d5cec39 | ||
|
|
70d66eb473 | ||
|
|
ffb087887a | ||
|
|
120dbd98ad | ||
|
|
f31e1b4643 | ||
|
|
5f8e886d3f | ||
|
|
7a37508b96 | ||
|
|
c4a3be5557 | ||
|
|
90bd8eb75a | ||
|
|
c179a8afee | ||
|
|
9f0468de48 | ||
|
|
ef93beb986 | ||
|
|
2dedb56b38 | ||
|
|
9b978c6a5f | ||
|
|
d102fe5ba0 | ||
|
|
353a283b40 | ||
|
|
e85ed294d7 | ||
|
|
58f35350fa | ||
|
|
a3e7dd69d6 | ||
|
|
4813595e40 | ||
|
|
ea86dde011 | ||
|
|
d0d4d0fd8f | ||
|
|
cfdd2ae698 | ||
|
|
f2ab24943d | ||
|
|
e6bc577379 | ||
|
|
c4fc24f38e | ||
|
|
066cc819a8 | ||
|
|
81ea129d80 | ||
|
|
af174f0c8c | ||
|
|
c11a5958a6 | ||
|
|
0e1c078ecd | ||
|
|
836a8702cc | ||
|
|
0d8ecab1ba | ||
|
|
ccf92cabdc | ||
|
|
7f0b4db9f8 | ||
|
|
76e62134a3 | ||
|
|
31f5a94098 | ||
|
|
a22300afcf | ||
|
|
717e42b383 | ||
|
|
91e043addc | ||
|
|
dd9726957f | ||
|
|
9230779af1 | ||
|
|
6bef6d879a | ||
|
|
ef6c7d9f0e | ||
|
|
4cc5411056 | ||
|
|
9d96fa7e53 |
@@ -79,9 +79,12 @@
|
||||
"proud-jeans-walk",
|
||||
"red-chefs-float",
|
||||
"shaggy-carrots-unite",
|
||||
"shaggy-parrots-smash",
|
||||
"shiny-chefs-heal",
|
||||
"smart-apricots-kneel",
|
||||
"sour-buses-shout",
|
||||
"spicy-frogs-press",
|
||||
"ten-parents-breathe",
|
||||
"tender-bags-call",
|
||||
"three-pots-sit",
|
||||
"two-dolls-check",
|
||||
|
||||
8
.changeset/shaggy-parrots-smash.md
Normal file
8
.changeset/shaggy-parrots-smash.md
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
'@verdaccio/cli': minor
|
||||
'@verdaccio/core': minor
|
||||
'@verdaccio/logger': minor
|
||||
'@verdaccio/node-api': minor
|
||||
---
|
||||
|
||||
feat: use warning codes for deprecation warnings
|
||||
11
.changeset/sour-buses-shout.md
Normal file
11
.changeset/sour-buses-shout.md
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
'@verdaccio/fastify-migration': minor
|
||||
'@verdaccio/store': minor
|
||||
'@verdaccio/utils': minor
|
||||
'@verdaccio/web': minor
|
||||
'@verdaccio/website': minor
|
||||
---
|
||||
|
||||
feat: migrate web sidebar endpoint to fastify
|
||||
|
||||
reuse utils methods between packages
|
||||
7
.changeset/ten-parents-breathe.md
Normal file
7
.changeset/ten-parents-breathe.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
'@verdaccio/auth': minor
|
||||
'@verdaccio/fastify-migration': minor
|
||||
'@verdaccio/web': minor
|
||||
---
|
||||
|
||||
dist tags Implementation on Fastify
|
||||
18
.github/workflows/ci.yml
vendored
18
.github/workflows/ci.yml
vendored
@@ -23,7 +23,7 @@ jobs:
|
||||
ports:
|
||||
- 4873:4873
|
||||
steps:
|
||||
- uses: actions/checkout@v2.3.1
|
||||
- uses: actions/checkout@v2.3.5
|
||||
- name: Use Node 14
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
name: Lint
|
||||
needs: prepare
|
||||
steps:
|
||||
- uses: actions/checkout@v2.3.1
|
||||
- uses: actions/checkout@v2.3.5
|
||||
- name: Use Node 16
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
@@ -68,7 +68,7 @@ jobs:
|
||||
name: Format
|
||||
needs: prepare
|
||||
steps:
|
||||
- uses: actions/checkout@v2.3.1
|
||||
- uses: actions/checkout@v2.3.5
|
||||
- name: Use Node 16
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
@@ -89,7 +89,7 @@ jobs:
|
||||
name: build
|
||||
needs: [format, lint]
|
||||
steps:
|
||||
- uses: actions/checkout@v2.3.1
|
||||
- uses: actions/checkout@v2.3.5
|
||||
- name: Use Node 16
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
@@ -131,7 +131,7 @@ jobs:
|
||||
name: ${{ matrix.os }} / Node ${{ matrix.node_version }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2.3.1
|
||||
- uses: actions/checkout@v2.3.5
|
||||
- name: Use Node ${{ matrix.node_version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
@@ -156,7 +156,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: UI Test E2E Node 14
|
||||
steps:
|
||||
- uses: actions/checkout@v2.3.1
|
||||
- uses: actions/checkout@v2.3.5
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 14
|
||||
@@ -183,7 +183,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: CLI Test E2E Node 14
|
||||
steps:
|
||||
- uses: actions/checkout@v2.3.1
|
||||
- uses: actions/checkout@v2.3.5
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 14
|
||||
@@ -210,7 +210,7 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
name: windows test node 14
|
||||
steps:
|
||||
- uses: actions/checkout@v2.3.1
|
||||
- uses: actions/checkout@v2.3.5
|
||||
- name: Use Node 14
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
@@ -234,7 +234,7 @@ jobs:
|
||||
name: synchronize translations
|
||||
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'workflow_dispatch'
|
||||
steps:
|
||||
- uses: actions/checkout@v2.3.1
|
||||
- uses: actions/checkout@v2.3.5
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 14
|
||||
|
||||
2
.github/workflows/codeql-analysis.yml
vendored
2
.github/workflows/codeql-analysis.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2.3.1
|
||||
uses: actions/checkout@v2.3.5
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
|
||||
2
.github/workflows/website.yml
vendored
2
.github/workflows/website.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
env:
|
||||
NODE_OPTIONS: --max_old_space_size=4096
|
||||
steps:
|
||||
- uses: actions/checkout@v2.3.1
|
||||
- uses: actions/checkout@v2.3.5
|
||||
|
||||
- name: Use Node 14
|
||||
uses: actions/setup-node@v2
|
||||
|
||||
11
.prettierrc
11
.prettierrc
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"endOfLine": "lf",
|
||||
"useTabs": false,
|
||||
"printWidth": 100,
|
||||
"tabWidth": 2,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": true,
|
||||
"jsxBracketSameLine": true,
|
||||
"trailingComma": "es5",
|
||||
"semi": true
|
||||
}
|
||||
@@ -129,9 +129,23 @@ More details in the debug section
|
||||
|
||||
### Running and debugging
|
||||
|
||||
> Check the debugging guidelines [here](https://github.com/verdaccio/verdaccio/wiki/Debugging-Verdaccio)
|
||||
|
||||
We use [`debug`](https://www.npmjs.com/package/debug) to add helpful debugging
|
||||
output to the code. Each package has it owns namespace.
|
||||
|
||||
#### Useful Scripts
|
||||
|
||||
To run the application from the source code, ensure the project has been built with `pnpm build`, once this is done, there are few commands that helps to run server:
|
||||
|
||||
- `pnpm start`: Run the server and the UI with `concurrently`, the
|
||||
server runs in the port `8000` and the UI on the port `4873`. This command
|
||||
is useful if you want to contribute mostly on the UI.
|
||||
- `pnpm debug`: Run the server in debug mode `--inspect`, the UI is included but does not have hot reload. For automatic break use `pnpm debug:break`.
|
||||
- `pnpm debug:fastify`: To contribute on the [fastify migration](https://github.com/verdaccio/verdaccio/discussions/2155) this is a temporary command for such purpose.
|
||||
- `pnpm website`: Build the website, for more commands to run the _website_, run `cd website` and then `pnpm serve`, website will run on port `3000`.
|
||||
- `pnpm docker`: Build the docker image. Requires `docker` command available in your system.
|
||||
|
||||
#### Debugging compiled code
|
||||
|
||||
Currently you can only run pre-compiled packages in debug mode. To enable debug
|
||||
|
||||
@@ -51,4 +51,4 @@ By default, the storage is taken from config file, but using this variable allow
|
||||
|
||||
#### VERDACCIO_STORAGE_NAME
|
||||
|
||||
The database name for `@verdaccio/local-storge` is by default `.verdaccio-db.json`, but this can be update by using this variable.
|
||||
The database name for `@verdaccio/local-storage` is by default `.verdaccio-db.json`, but this can be update by using this variable.
|
||||
|
||||
29
docs/warnings.md
Normal file
29
docs/warnings.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Warning Codes
|
||||
|
||||
## VERWAR001
|
||||
|
||||
Verdaccio doesn't need superuser privileges. Don't run it under root.
|
||||
|
||||
## VERWAR002
|
||||
|
||||
logger is not defined
|
||||
|
||||
## VERWAR003
|
||||
|
||||
'rotating-file type is not longer supported, consider use [logrotate] instead'
|
||||
|
||||
## VERWAR004
|
||||
|
||||
invalid address - xxxxxx, we expect a port (e.g. "4873"),
|
||||
|
||||
## VERDEP001
|
||||
|
||||
'config.logs is deprecated, rename configuration to "config.log" in singular'
|
||||
|
||||
## VERDEP002
|
||||
|
||||
'deprecate: multiple logger configuration is deprecated, please check the migration guide.'
|
||||
|
||||
## VERDEP003
|
||||
|
||||
'multiple addresses will be deprecated in the next major, only use one'
|
||||
60
package.json
60
package.json
@@ -15,25 +15,25 @@
|
||||
"url": "https://opencollective.com/verdaccio"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "7.15.4",
|
||||
"@babel/core": "7.15.5",
|
||||
"@babel/node": "7.15.4",
|
||||
"@babel/cli": "7.15.7",
|
||||
"@babel/core": "7.15.8",
|
||||
"@babel/node": "7.15.8",
|
||||
"@babel/plugin-proposal-class-properties": "7.14.5",
|
||||
"@babel/plugin-proposal-decorators": "7.15.4",
|
||||
"@babel/plugin-proposal-decorators": "7.15.8",
|
||||
"@babel/plugin-proposal-export-namespace-from": "7.14.5",
|
||||
"@babel/plugin-proposal-function-sent": "7.14.5",
|
||||
"@babel/plugin-proposal-json-strings": "7.14.5",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "7.14.5",
|
||||
"@babel/plugin-proposal-numeric-separator": "7.14.5",
|
||||
"@babel/plugin-proposal-object-rest-spread": "7.14.7",
|
||||
"@babel/plugin-proposal-object-rest-spread": "7.15.6",
|
||||
"@babel/plugin-proposal-optional-chaining": "7.14.5",
|
||||
"@babel/plugin-proposal-throw-expressions": "7.14.5",
|
||||
"@babel/plugin-syntax-dynamic-import": "7.8.3",
|
||||
"@babel/plugin-syntax-import-meta": "7.10.4",
|
||||
"@babel/plugin-transform-async-to-generator": "7.14.5",
|
||||
"@babel/plugin-transform-classes": "7.15.4",
|
||||
"@babel/plugin-transform-runtime": "7.15.0",
|
||||
"@babel/preset-env": "7.15.4",
|
||||
"@babel/plugin-transform-runtime": "7.15.8",
|
||||
"@babel/preset-env": "7.15.8",
|
||||
"@babel/preset-react": "7.14.5",
|
||||
"@babel/preset-typescript": "7.15.0",
|
||||
"@babel/register": "7.15.3",
|
||||
@@ -41,65 +41,66 @@
|
||||
"@changesets/changelog-github": "0.2.8",
|
||||
"@changesets/cli": "2.15.0",
|
||||
"@changesets/get-dependents-graph": "1.2.2",
|
||||
"@crowdin/cli": "3.6.5",
|
||||
"@crowdin/cli": "3.7.1",
|
||||
"@trivago/prettier-plugin-sort-imports": "3.0.0",
|
||||
"@types/async": "3.2.7",
|
||||
"@types/autocannon": "4.1.1",
|
||||
"@types/autosuggest-highlight": "3.1.1",
|
||||
"@types/express": "4.17.6",
|
||||
"@types/express": "4.17.13",
|
||||
"@types/http-errors": "1.8.1",
|
||||
"@types/jest": "27.0.1",
|
||||
"@types/lodash": "4.14.172",
|
||||
"@types/jest": "27.0.2",
|
||||
"@types/lodash": "4.14.176",
|
||||
"@types/mime": "2.0.3",
|
||||
"@types/minimatch": "3.0.5",
|
||||
"@types/node": "14.6.0",
|
||||
"@types/request": "2.48.7",
|
||||
"@types/semver": "7.3.8",
|
||||
"@types/semver": "7.3.9",
|
||||
"@types/supertest": "2.0.11",
|
||||
"@types/testing-library__jest-dom": "5.14.1",
|
||||
"@types/validator": "13.6.3",
|
||||
"@types/validator": "13.6.6",
|
||||
"@types/webpack": "5.28.0",
|
||||
"@types/webpack-env": "1.16.2",
|
||||
"@typescript-eslint/eslint-plugin": "4.30.0",
|
||||
"@typescript-eslint/parser": "4.30.0",
|
||||
"@types/webpack-env": "1.16.3",
|
||||
"@typescript-eslint/eslint-plugin": "4.33.0",
|
||||
"@typescript-eslint/parser": "4.33.0",
|
||||
"@verdaccio/benchmark": "workspace:*",
|
||||
"@verdaccio/eslint-config": "workspace:*",
|
||||
"@verdaccio/types": "workspace:*",
|
||||
"@verdaccio/ui-theme": "workspace:*",
|
||||
"autocannon": "7.4.0",
|
||||
"autocannon": "7.5.0",
|
||||
"babel-core": "7.0.0-bridge.0",
|
||||
"babel-eslint": "10.1.0",
|
||||
"babel-jest": "27.1.0",
|
||||
"babel-jest": "27.3.1",
|
||||
"babel-plugin-dynamic-import-node": "2.3.3",
|
||||
"babel-plugin-emotion": "10.2.2",
|
||||
"codecov": "3.8.3",
|
||||
"concurrently": "6.2.1",
|
||||
"concurrently": "6.3.0",
|
||||
"core-js": "3.17.2",
|
||||
"cross-env": "7.0.3",
|
||||
"debug": "4.3.2",
|
||||
"detect-secrets": "1.0.6",
|
||||
"eslint": "7.32.0",
|
||||
"fs-extra": "10.0.0",
|
||||
"husky": "7.0.2",
|
||||
"husky": "7.0.4",
|
||||
"in-publish": "2.0.1",
|
||||
"jest": "27.1.0",
|
||||
"jest-environment-jsdom": "27.1.0",
|
||||
"jest": "27.3.1",
|
||||
"jest-environment-jsdom": "27.3.1",
|
||||
"jest-environment-jsdom-global": "3.0.0",
|
||||
"jest-environment-node": "27.1.0",
|
||||
"jest-junit": "12.2.0",
|
||||
"jest-environment-node": "27.3.1",
|
||||
"jest-junit": "12.3.0",
|
||||
"kleur": "3.0.3",
|
||||
"lint-staged": "11.1.2",
|
||||
"nock": "12.0.3",
|
||||
"node-fetch": "3.0.0-beta.6-exportfix",
|
||||
"nodemon": "2.0.12",
|
||||
"nodemon": "2.0.14",
|
||||
"npm-run-all": "4.1.5",
|
||||
"prettier": "2.3.2",
|
||||
"rimraf": "3.0.2",
|
||||
"selfsigned": "1.10.11",
|
||||
"supertest": "6.1.6",
|
||||
"ts-node": "10.2.1",
|
||||
"typescript": "4.4.2",
|
||||
"update-ts-references": "2.4.0",
|
||||
"verdaccio": "5.1.3",
|
||||
"typescript": "4.4.4",
|
||||
"update-ts-references": "2.4.1",
|
||||
"verdaccio": "5.2.0",
|
||||
"verdaccio-audit": "workspace:*",
|
||||
"verdaccio-auth-memory": "workspace:*",
|
||||
"verdaccio-htpasswd": "workspace:*",
|
||||
@@ -112,7 +113,7 @@
|
||||
"docker": "docker build -t verdaccio/verdaccio:local . --no-cache",
|
||||
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,yml,yaml,md}\"",
|
||||
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,yml,yaml,md}\"",
|
||||
"lint": "eslint --max-warnings 60 \"**/*.{js,jsx,ts,tsx}\"",
|
||||
"lint": "eslint --max-warnings 46 \"**/*.{js,jsx,ts,tsx}\"",
|
||||
"test": "pnpm recursive test --filter ./packages",
|
||||
"test:e2e:cli": "pnpm test --filter ...@verdaccio/e2e-cli",
|
||||
"test:e2e:ui": "pnpm test --filter ...@verdaccio/e2e-ui",
|
||||
@@ -127,6 +128,7 @@
|
||||
"_debug:reload": "nodemon -d 3 packages/verdaccio/debug/bootstrap.js",
|
||||
"start:ts": "ts-node packages/verdaccio/src/start.ts -- --listen 8000",
|
||||
"debug": "node --trace-warnings --trace-uncaught --inspect packages/verdaccio/debug/bootstrap.js",
|
||||
"debug:fastify": "node --trace-warnings --trace-uncaught --inspect packages/verdaccio/debug/bootstrap.js -- fastify-server",
|
||||
"debug:break": "node --trace-warnings --trace-uncaught --inspect-brk packages/verdaccio/debug/bootstrap.js",
|
||||
"changeset": "changeset",
|
||||
"changeset:check": "changeset status --since-master",
|
||||
|
||||
@@ -1,5 +1,34 @@
|
||||
# @verdaccio/api
|
||||
|
||||
## 6.0.0-6-next.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [f86c31ed]
|
||||
- Updated dependencies [20c9e43e]
|
||||
- @verdaccio/store@6.0.0-6-next.16
|
||||
- @verdaccio/utils@6.0.0-6-next.9
|
||||
- @verdaccio/auth@6.0.0-6-next.15
|
||||
- @verdaccio/config@6.0.0-6-next.11
|
||||
- @verdaccio/tarball@11.0.0-6-next.10
|
||||
- @verdaccio/middleware@6.0.0-6-next.15
|
||||
- @verdaccio/hooks@6.0.0-6-next.9
|
||||
|
||||
## 6.0.0-6-next.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6c1eb021]
|
||||
- @verdaccio/core@6.0.0-6-next.3
|
||||
- @verdaccio/logger@6.0.0-6-next.7
|
||||
- @verdaccio/auth@6.0.0-6-next.14
|
||||
- @verdaccio/config@6.0.0-6-next.10
|
||||
- @verdaccio/tarball@11.0.0-6-next.9
|
||||
- @verdaccio/hooks@6.0.0-6-next.9
|
||||
- @verdaccio/middleware@6.0.0-6-next.14
|
||||
- @verdaccio/store@6.0.0-6-next.15
|
||||
- @verdaccio/utils@6.0.0-6-next.8
|
||||
|
||||
## 6.0.0-6-next.16
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/api",
|
||||
"version": "6.0.0-6-next.16",
|
||||
"version": "6.0.0-6-next.18",
|
||||
"description": "loaders logic",
|
||||
"main": "./build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
@@ -39,15 +39,15 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@verdaccio/auth": "workspace:6.0.0-6-next.13",
|
||||
"@verdaccio/config": "workspace:6.0.0-6-next.9",
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.2",
|
||||
"@verdaccio/hooks": "workspace:6.0.0-6-next.8",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.6",
|
||||
"@verdaccio/middleware": "workspace:6.0.0-6-next.13",
|
||||
"@verdaccio/store": "workspace:6.0.0-6-next.14",
|
||||
"@verdaccio/tarball": "workspace:11.0.0-6-next.8",
|
||||
"@verdaccio/utils": "workspace:6.0.0-6-next.7",
|
||||
"@verdaccio/auth": "workspace:6.0.0-6-next.15",
|
||||
"@verdaccio/config": "workspace:6.0.0-6-next.11",
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.3",
|
||||
"@verdaccio/hooks": "workspace:6.0.0-6-next.9",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.7",
|
||||
"@verdaccio/middleware": "workspace:6.0.0-6-next.15",
|
||||
"@verdaccio/store": "workspace:6.0.0-6-next.16",
|
||||
"@verdaccio/tarball": "workspace:11.0.0-6-next.10",
|
||||
"@verdaccio/utils": "workspace:6.0.0-6-next.9",
|
||||
"abortcontroller-polyfill": "1.7.3",
|
||||
"cookies": "0.8.0",
|
||||
"debug": "4.3.2",
|
||||
@@ -57,8 +57,8 @@
|
||||
"semver": "7.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "16.9.1",
|
||||
"@verdaccio/server": "workspace:6.0.0-6-next.21",
|
||||
"@types/node": "16.11.6",
|
||||
"@verdaccio/server": "workspace:6.0.0-6-next.23",
|
||||
"@verdaccio/types": "workspace:11.0.0-6-next.9",
|
||||
"@verdaccio/helper": "1.0.0",
|
||||
"body-parser": "1.19.0",
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import mime from 'mime';
|
||||
import _ from 'lodash';
|
||||
import { Router } from 'express';
|
||||
import _ from 'lodash';
|
||||
import mime from 'mime';
|
||||
|
||||
import { media, allow } from '@verdaccio/middleware';
|
||||
import { constants, VerdaccioError } from '@verdaccio/core';
|
||||
import { Package } from '@verdaccio/types';
|
||||
import { Storage } from '@verdaccio/store';
|
||||
import { IAuth } from '@verdaccio/auth';
|
||||
import { VerdaccioError, constants } from '@verdaccio/core';
|
||||
import { allow, media } from '@verdaccio/middleware';
|
||||
import { Storage } from '@verdaccio/store';
|
||||
import { Package } from '@verdaccio/types';
|
||||
|
||||
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';
|
||||
|
||||
export default function (route: Router, auth: IAuth, storage: Storage): void {
|
||||
|
||||
@@ -1,28 +1,29 @@
|
||||
import bodyParser from 'body-parser';
|
||||
import express, { Router } from 'express';
|
||||
import semver from 'semver';
|
||||
|
||||
import { IAuth } from '@verdaccio/auth';
|
||||
import {
|
||||
antiLoop,
|
||||
encodeScopePackage,
|
||||
match,
|
||||
validateName,
|
||||
validatePackage,
|
||||
encodeScopePackage,
|
||||
antiLoop,
|
||||
} from '@verdaccio/middleware';
|
||||
import { IAuth } from '@verdaccio/auth';
|
||||
import { Storage } from '@verdaccio/store';
|
||||
import { Config } from '@verdaccio/types';
|
||||
import bodyParser from 'body-parser';
|
||||
import semver from 'semver';
|
||||
|
||||
import whoami from './whoami';
|
||||
import ping from './ping';
|
||||
import user from './user';
|
||||
import distTags from './dist-tags';
|
||||
import pkg from './package';
|
||||
import ping from './ping';
|
||||
import publish from './publish';
|
||||
import search from './search';
|
||||
import pkg from './package';
|
||||
import stars from './stars';
|
||||
import user from './user';
|
||||
import profile from './v1/profile';
|
||||
import token from './v1/token';
|
||||
import v1Search from './v1/search';
|
||||
import token from './v1/token';
|
||||
import whoami from './whoami';
|
||||
|
||||
if (semver.lte(process.version, 'v15.0.0')) {
|
||||
global.AbortController = require('abortcontroller-polyfill/dist/cjs-ponyfill').AbortController;
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import _ from 'lodash';
|
||||
import { Router } from 'express';
|
||||
import buildDebug from 'debug';
|
||||
import { Router } from 'express';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { allow } from '@verdaccio/middleware';
|
||||
import { getVersion } from '@verdaccio/utils';
|
||||
import { HEADERS, DIST_TAGS, API_ERROR, errorUtils } from '@verdaccio/core';
|
||||
import { Config, Package } from '@verdaccio/types';
|
||||
import { IAuth } from '@verdaccio/auth';
|
||||
import { API_ERROR, DIST_TAGS, HEADERS, errorUtils } from '@verdaccio/core';
|
||||
import { allow } from '@verdaccio/middleware';
|
||||
import { Storage } from '@verdaccio/store';
|
||||
import { convertDistRemoteToLocalTarballUrls } from '@verdaccio/tarball';
|
||||
import { $RequestExtend, $ResponseExtend, $NextFunctionVer } from '../types/custom';
|
||||
import { Config, Package } from '@verdaccio/types';
|
||||
import { getVersion } from '@verdaccio/utils';
|
||||
|
||||
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';
|
||||
|
||||
const debug = buildDebug('verdaccio:api:package');
|
||||
|
||||
@@ -40,7 +41,7 @@ export default function (route: Router, auth: IAuth, storage: Storage, config: C
|
||||
route.get(
|
||||
'/:package/:version?',
|
||||
can('access'),
|
||||
function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
|
||||
function (req: $RequestExtend, _res: $ResponseExtend, next: $NextFunctionVer): void {
|
||||
debug('init package by version');
|
||||
const name = req.params.package;
|
||||
const getPackageMetaCallback = function (err, metadata: Package): void {
|
||||
@@ -49,7 +50,11 @@ export default function (route: Router, auth: IAuth, storage: Storage, config: C
|
||||
return next(err);
|
||||
}
|
||||
debug('convert dist remote to local with prefix %o', config?.url_prefix);
|
||||
metadata = convertDistRemoteToLocalTarballUrls(metadata, req, config?.url_prefix);
|
||||
metadata = convertDistRemoteToLocalTarballUrls(
|
||||
metadata,
|
||||
{ protocol: req.protocol, headers: req.headers as any, host: req.host },
|
||||
config?.url_prefix
|
||||
);
|
||||
|
||||
let queryVersion = req.params.version;
|
||||
debug('query by param version: %o', queryVersion);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Router } from 'express';
|
||||
import { $RequestExtend, $ResponseExtend, $NextFunctionVer } from '../types/custom';
|
||||
|
||||
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';
|
||||
|
||||
export default function (route: Router): void {
|
||||
route.get(
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
import Path from 'path';
|
||||
import buildDebug from 'debug';
|
||||
import { Router } from 'express';
|
||||
import _ from 'lodash';
|
||||
import mime from 'mime';
|
||||
import { Router } from 'express';
|
||||
import buildDebug from 'debug';
|
||||
import Path from 'path';
|
||||
|
||||
import { IAuth } from '@verdaccio/auth';
|
||||
import {
|
||||
API_MESSAGE,
|
||||
HEADERS,
|
||||
DIST_TAGS,
|
||||
API_ERROR,
|
||||
API_MESSAGE,
|
||||
DIST_TAGS,
|
||||
HEADERS,
|
||||
HTTP_STATUS,
|
||||
errorUtils,
|
||||
} from '@verdaccio/core';
|
||||
import { validateMetadata, isObject, hasDiffOneKey } from '@verdaccio/utils';
|
||||
import { media, expectJson, allow } from '@verdaccio/middleware';
|
||||
import { notify } from '@verdaccio/hooks';
|
||||
import { Config, Callback, MergeTags, Version, Package, CallbackAction } from '@verdaccio/types';
|
||||
import { logger } from '@verdaccio/logger';
|
||||
import { IAuth } from '@verdaccio/auth';
|
||||
import { allow, expectJson, media } from '@verdaccio/middleware';
|
||||
import { Storage } from '@verdaccio/store';
|
||||
import { $RequestExtend, $ResponseExtend, $NextFunctionVer } from '../types/custom';
|
||||
import { Callback, CallbackAction, Config, MergeTags, Package, Version } from '@verdaccio/types';
|
||||
import { hasDiffOneKey, isObject, validateMetadata } from '@verdaccio/utils';
|
||||
|
||||
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';
|
||||
import star from './star';
|
||||
import { isPublishablePackage, isRelatedToDeprecation } from './utils';
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { USERS, HTTP_STATUS } from '@verdaccio/core';
|
||||
import buildDebug from 'debug';
|
||||
import { Response } from 'express';
|
||||
import _ from 'lodash';
|
||||
import buildDebug from 'debug';
|
||||
|
||||
import { HTTP_STATUS, USERS } from '@verdaccio/core';
|
||||
import { Storage } from '@verdaccio/store';
|
||||
import { $RequestExtend, $NextFunctionVer } from '../types/custom';
|
||||
|
||||
import { $NextFunctionVer, $RequestExtend } from '../types/custom';
|
||||
|
||||
const debug = buildDebug('verdaccio:api:publish:star');
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import _ from 'lodash';
|
||||
import { Response, Router } from 'express';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { USERS, HTTP_STATUS } from '@verdaccio/core';
|
||||
import { HTTP_STATUS, USERS } from '@verdaccio/core';
|
||||
import { Storage } from '@verdaccio/store';
|
||||
import { Package } from '@verdaccio/types';
|
||||
|
||||
import { Storage } from '@verdaccio/store';
|
||||
import { $RequestExtend, $NextFunctionVer } from '../types/custom';
|
||||
import { $NextFunctionVer, $RequestExtend } from '../types/custom';
|
||||
|
||||
type Packages = Package[];
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import _ from 'lodash';
|
||||
import { Response, Router } from 'express';
|
||||
import buildDebug from 'debug';
|
||||
import { Response, Router } from 'express';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { getAuthenticatedMessage, validatePassword } from '@verdaccio/utils';
|
||||
import { getApiToken } from '@verdaccio/auth';
|
||||
import { logger } from '@verdaccio/logger';
|
||||
import { createRemoteUser } from '@verdaccio/config';
|
||||
|
||||
import { Config, RemoteUser } from '@verdaccio/types';
|
||||
import { IAuth } from '@verdaccio/auth';
|
||||
import { createRemoteUser } from '@verdaccio/config';
|
||||
import { API_ERROR, API_MESSAGE, HTTP_STATUS, errorUtils } from '@verdaccio/core';
|
||||
import { $RequestExtend, $NextFunctionVer } from '../types/custom';
|
||||
import { logger } from '@verdaccio/logger';
|
||||
import { Config, RemoteUser } from '@verdaccio/types';
|
||||
import { getAuthenticatedMessage, validatePassword } from '@verdaccio/utils';
|
||||
|
||||
import { $NextFunctionVer, $RequestExtend } from '../types/custom';
|
||||
|
||||
const debug = buildDebug('verdaccio:api:user');
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Package } from '@verdaccio/types';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { Package } from '@verdaccio/types';
|
||||
|
||||
/**
|
||||
* Check whether the package metadta has enough data to be published
|
||||
* @param pkg metadata
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import _ from 'lodash';
|
||||
import { Response, Router } from 'express';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { IAuth } from '@verdaccio/auth';
|
||||
import { API_ERROR, APP_ERROR, HTTP_STATUS, SUPPORT_ERRORS, errorUtils } from '@verdaccio/core';
|
||||
import { validatePassword } from '@verdaccio/utils';
|
||||
import { IAuth } from '@verdaccio/auth';
|
||||
import { $RequestExtend, $NextFunctionVer } from '../../types/custom';
|
||||
|
||||
import { $NextFunctionVer, $RequestExtend } from '../../types/custom';
|
||||
|
||||
export interface Profile {
|
||||
tfa: boolean;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import _ from 'lodash';
|
||||
import buildDebug from 'debug';
|
||||
import { logger } from '@verdaccio/logger';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { IAuth } from '@verdaccio/auth';
|
||||
import { HTTP_STATUS, searchUtils } from '@verdaccio/core';
|
||||
import { logger } from '@verdaccio/logger';
|
||||
import { Storage } from '@verdaccio/store';
|
||||
import { Package } from '@verdaccio/types';
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import _ from 'lodash';
|
||||
import { errorUtils, HTTP_STATUS, SUPPORT_ERRORS } from '@verdaccio/core';
|
||||
import { stringToMD5, mask } from '@verdaccio/utils';
|
||||
import { getApiToken } from '@verdaccio/auth';
|
||||
import { logger } from '@verdaccio/logger';
|
||||
import { Response, Router } from 'express';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { Config, RemoteUser, Token } from '@verdaccio/types';
|
||||
import { getApiToken } from '@verdaccio/auth';
|
||||
import { IAuth } from '@verdaccio/auth';
|
||||
import { HTTP_STATUS, SUPPORT_ERRORS, errorUtils } from '@verdaccio/core';
|
||||
import { logger } from '@verdaccio/logger';
|
||||
import { Storage } from '@verdaccio/store';
|
||||
import { $RequestExtend, $NextFunctionVer } from '../../types/custom';
|
||||
import { Config, RemoteUser, Token } from '@verdaccio/types';
|
||||
import { mask, stringToMD5 } from '@verdaccio/utils';
|
||||
|
||||
import { $NextFunctionVer, $RequestExtend } from '../../types/custom';
|
||||
|
||||
export type NormalizeToken = Token & {
|
||||
created: string;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Response, Router } from 'express';
|
||||
import buildDebug from 'debug';
|
||||
import { $RequestExtend, $NextFunctionVer } from '../types/custom';
|
||||
import { Response, Router } from 'express';
|
||||
|
||||
import { $NextFunctionVer, $RequestExtend } from '../types/custom';
|
||||
|
||||
const debug = buildDebug('verdaccio:api:user');
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import path from 'path';
|
||||
import express, { Application } from 'express';
|
||||
import supertest from 'supertest';
|
||||
import bodyParser from 'body-parser';
|
||||
import express, { Application } from 'express';
|
||||
import path from 'path';
|
||||
import supertest from 'supertest';
|
||||
|
||||
import { Config, parseConfigFile } from '@verdaccio/config';
|
||||
import { Storage } from '@verdaccio/store';
|
||||
import { generatePackageMetadata } from '@verdaccio/helper';
|
||||
import { final, handleError, errorReportingMiddleware } from '@verdaccio/middleware';
|
||||
import { Auth, IAuth } from '@verdaccio/auth';
|
||||
import { Config, parseConfigFile } from '@verdaccio/config';
|
||||
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
||||
import { generatePackageMetadata } from '@verdaccio/helper';
|
||||
import { errorReportingMiddleware, final, handleError } from '@verdaccio/middleware';
|
||||
import { Storage } from '@verdaccio/store';
|
||||
|
||||
import apiEndpoints from '../../src';
|
||||
|
||||
const getConf = (conf) => {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import supertest from 'supertest';
|
||||
|
||||
import { HEADER_TYPE, HEADERS, HTTP_STATUS } from '@verdaccio/core';
|
||||
import { $ResponseExtend, $RequestExtend } from '../../types/custom';
|
||||
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
||||
|
||||
import { $RequestExtend, $ResponseExtend } from '../../types/custom';
|
||||
import { initializeServer, publishTaggedVersion, publishVersion } from './_helper';
|
||||
|
||||
const mockApiJWTmiddleware = jest.fn(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import supertest from 'supertest';
|
||||
|
||||
import { HEADER_TYPE, HEADERS, HTTP_STATUS } from '@verdaccio/core';
|
||||
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
||||
|
||||
import { initializeServer } from './_helper';
|
||||
|
||||
describe('ping', () => {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { HTTP_STATUS } from '@verdaccio/core';
|
||||
import supertest from 'supertest';
|
||||
import { API_ERROR, API_MESSAGE, HEADER_TYPE, HEADERS } from '@verdaccio/core';
|
||||
|
||||
import { HTTP_STATUS } from '@verdaccio/core';
|
||||
import { API_ERROR, API_MESSAGE, HEADERS, HEADER_TYPE } from '@verdaccio/core';
|
||||
import { generatePackageMetadata } from '@verdaccio/helper';
|
||||
import { $ResponseExtend, $RequestExtend } from '../../types/custom';
|
||||
|
||||
import { $RequestExtend, $ResponseExtend } from '../../types/custom';
|
||||
import { initializeServer, publishVersion } from './_helper';
|
||||
|
||||
const mockApiJWTmiddleware = jest.fn(
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import supertest from 'supertest';
|
||||
import _ from 'lodash';
|
||||
import supertest from 'supertest';
|
||||
|
||||
import {
|
||||
errorUtils,
|
||||
API_ERROR,
|
||||
API_MESSAGE,
|
||||
HEADERS,
|
||||
HEADER_TYPE,
|
||||
API_MESSAGE,
|
||||
HTTP_STATUS,
|
||||
API_ERROR,
|
||||
errorUtils,
|
||||
} from '@verdaccio/core';
|
||||
|
||||
import { $RequestExtend, $ResponseExtend } from '../../types/custom';
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { errorUtils, HTTP_STATUS, API_ERROR } from '@verdaccio/core';
|
||||
import { API_ERROR, HTTP_STATUS, errorUtils } from '@verdaccio/core';
|
||||
|
||||
import {
|
||||
addVersion,
|
||||
uploadPackageTarball,
|
||||
publishPackage,
|
||||
removeTarball,
|
||||
unPublishPackage,
|
||||
publishPackage,
|
||||
uploadPackageTarball,
|
||||
} from '../../src/publish';
|
||||
|
||||
const REVISION_MOCK = '15-e53a77096b0ee33e';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable curly */
|
||||
// ensure that all arguments are validated
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
/**
|
||||
* Validate.
|
||||
|
||||
3
packages/api/types/custom.d.ts
vendored
3
packages/api/types/custom.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
import { Logger, RemoteUser } from '@verdaccio/types';
|
||||
import { NextFunction, Request, Response } from 'express';
|
||||
|
||||
import { Logger, RemoteUser } from '@verdaccio/types';
|
||||
|
||||
export type $RequestExtend = Request & { remote_user?: any; log: Logger };
|
||||
export type $ResponseExtend = Response & { cookies?: any };
|
||||
export type $NextFunctionVer = NextFunction & any;
|
||||
|
||||
@@ -1,5 +1,30 @@
|
||||
# @verdaccio/auth
|
||||
|
||||
## 6.0.0-6-next.15
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 20c9e43e: dist tags Implementation on Fastify
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [f86c31ed]
|
||||
- @verdaccio/utils@6.0.0-6-next.9
|
||||
- @verdaccio/config@6.0.0-6-next.11
|
||||
- @verdaccio/loaders@6.0.0-6-next.7
|
||||
|
||||
## 6.0.0-6-next.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6c1eb021]
|
||||
- @verdaccio/core@6.0.0-6-next.3
|
||||
- @verdaccio/logger@6.0.0-6-next.7
|
||||
- @verdaccio/config@6.0.0-6-next.10
|
||||
- @verdaccio/loaders@6.0.0-6-next.7
|
||||
- verdaccio-htpasswd@11.0.0-6-next.10
|
||||
- @verdaccio/utils@6.0.0-6-next.8
|
||||
|
||||
## 6.0.0-6-next.13
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/auth",
|
||||
"version": "6.0.0-6-next.13",
|
||||
"version": "6.0.0-6-next.15",
|
||||
"description": "logger",
|
||||
"main": "./build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
@@ -39,19 +39,19 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.2",
|
||||
"@verdaccio/config": "workspace:6.0.0-6-next.9",
|
||||
"@verdaccio/loaders": "workspace:6.0.0-6-next.6",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.6",
|
||||
"@verdaccio/utils": "workspace:6.0.0-6-next.7",
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.3",
|
||||
"@verdaccio/config": "workspace:6.0.0-6-next.11",
|
||||
"@verdaccio/loaders": "workspace:6.0.0-6-next.7",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.7",
|
||||
"@verdaccio/utils": "workspace:6.0.0-6-next.9",
|
||||
"debug": "4.3.2",
|
||||
"express": "4.17.1",
|
||||
"jsonwebtoken": "8.5.1",
|
||||
"lodash": "4.17.21",
|
||||
"verdaccio-htpasswd": "workspace:11.0.0-6-next.9"
|
||||
"verdaccio-htpasswd": "workspace:11.0.0-6-next.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@verdaccio/mock": "workspace:6.0.0-6-next.10",
|
||||
"@verdaccio/mock": "workspace:6.0.0-6-next.12",
|
||||
"@verdaccio/types": "workspace:11.0.0-6-next.9"
|
||||
},
|
||||
"funding": {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import _ from 'lodash';
|
||||
import { NextFunction, Request, Response } from 'express';
|
||||
import buildDebug from 'debug';
|
||||
import { NextFunction, Request, Response } from 'express';
|
||||
import _ from 'lodash';
|
||||
import { HTPasswd, HTPasswdConfig } from 'verdaccio-htpasswd';
|
||||
|
||||
import { createAnonymousRemoteUser, createRemoteUser } from '@verdaccio/config';
|
||||
import {
|
||||
API_ERROR,
|
||||
SUPPORT_ERRORS,
|
||||
@@ -11,38 +13,33 @@ import {
|
||||
errorUtils,
|
||||
} from '@verdaccio/core';
|
||||
import { loadPlugin } from '@verdaccio/loaders';
|
||||
import { HTPasswd, HTPasswdConfig } from 'verdaccio-htpasswd';
|
||||
|
||||
import {
|
||||
Config,
|
||||
Logger,
|
||||
Callback,
|
||||
IPluginAuth,
|
||||
RemoteUser,
|
||||
JWTSignOptions,
|
||||
Security,
|
||||
AuthPluginPackage,
|
||||
AllowAccess,
|
||||
AuthPluginPackage,
|
||||
Callback,
|
||||
Config,
|
||||
IPluginAuth,
|
||||
JWTSignOptions,
|
||||
Logger,
|
||||
PackageAccess,
|
||||
PluginOptions,
|
||||
RemoteUser,
|
||||
Security,
|
||||
} from '@verdaccio/types';
|
||||
|
||||
import { getMatchedPackagesSpec, isNil, isFunction } from '@verdaccio/utils';
|
||||
import { createAnonymousRemoteUser, createRemoteUser } from '@verdaccio/config';
|
||||
|
||||
import {
|
||||
getMiddlewareCredentials,
|
||||
getDefaultPlugins,
|
||||
verifyJWTPayload,
|
||||
parseAuthTokenHeader,
|
||||
isAuthHeaderValid,
|
||||
isAESLegacy,
|
||||
convertPayloadToBase64,
|
||||
} from './utils';
|
||||
import { getMatchedPackagesSpec, isFunction, isNil } from '@verdaccio/utils';
|
||||
|
||||
import { signPayload } from './jwt-token';
|
||||
import { aesEncrypt } from './legacy-token';
|
||||
import { parseBasicPayload } from './token';
|
||||
import {
|
||||
convertPayloadToBase64,
|
||||
getDefaultPlugins,
|
||||
getMiddlewareCredentials,
|
||||
isAESLegacy,
|
||||
isAuthHeaderValid,
|
||||
parseAuthTokenHeader,
|
||||
verifyJWTPayload,
|
||||
} from './utils';
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const LoggerApi = require('@verdaccio/logger');
|
||||
@@ -52,6 +49,7 @@ const debug = buildDebug('verdaccio:auth');
|
||||
export interface IBasicAuth<T> {
|
||||
config: T & Config;
|
||||
authenticate(user: string, password: string, cb: Callback): void;
|
||||
invalidateToken?(token: string): Promise<void>;
|
||||
changePassword(user: string, password: string, newPassword: string, cb: Callback): void;
|
||||
allow_access(pkg: AuthPluginPackage, user: RemoteUser, callback: Callback): void;
|
||||
add_user(user: string, password: string, cb: Callback): any;
|
||||
@@ -83,6 +81,7 @@ export interface IAuth extends IBasicAuth<Config>, IAuthMiddleware, TokenEncrypt
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
plugins: any[];
|
||||
allow_unpublish(pkg: AuthPluginPackage, user: RemoteUser, callback: Callback): void;
|
||||
invalidateToken(token: string): Promise<void>;
|
||||
}
|
||||
|
||||
class Auth implements IAuth {
|
||||
@@ -95,6 +94,9 @@ class Auth implements IAuth {
|
||||
this.config = config;
|
||||
this.logger = LoggerApi.logger.child({ sub: 'auth' });
|
||||
this.secret = config.secret;
|
||||
if (!this.secret) {
|
||||
throw new TypeError('secret it is required value on initialize the auth class');
|
||||
}
|
||||
|
||||
this.plugins =
|
||||
_.isNil(config?.auth) === false ? this._loadPlugin(config) : this.loadDefaultPlugin(config);
|
||||
@@ -177,6 +179,12 @@ class Auth implements IAuth {
|
||||
}
|
||||
}
|
||||
|
||||
public async invalidateToken(token: string) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('invalidate token pending to implement', token);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
public authenticate(username: string, password: string, cb: Callback): void {
|
||||
const plugins = this.plugins.slice(0);
|
||||
(function next(): void {
|
||||
@@ -413,7 +421,9 @@ class Auth implements IAuth {
|
||||
}
|
||||
|
||||
// in case auth header does not exist we return anonymous function
|
||||
req.remote_user = createAnonymousRemoteUser();
|
||||
const remoteUser = createAnonymousRemoteUser();
|
||||
req.remote_user = remoteUser;
|
||||
res.locals.remote_user = remoteUser;
|
||||
|
||||
const { authorization } = req.headers;
|
||||
if (_.isNil(authorization)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import jwt from 'jsonwebtoken';
|
||||
import buildDebug from 'debug';
|
||||
import jwt from 'jsonwebtoken';
|
||||
|
||||
import { JWTSignOptions, RemoteUser } from '@verdaccio/types';
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import {
|
||||
HexBase64BinaryEncoding,
|
||||
Utf8AsciiBinaryEncoding,
|
||||
createCipheriv,
|
||||
createDecipheriv,
|
||||
HexBase64BinaryEncoding,
|
||||
randomBytes,
|
||||
Utf8AsciiBinaryEncoding,
|
||||
} from 'crypto';
|
||||
import { TOKEN_VALID_LENGTH } from '@verdaccio/config';
|
||||
import buildDebug from 'debug';
|
||||
|
||||
import { TOKEN_VALID_LENGTH } from '@verdaccio/config';
|
||||
|
||||
const debug = buildDebug('verdaccio:auth:token:legacy');
|
||||
|
||||
export const defaultAlgorithm = process.env.VERDACCIO_LEGACY_ALGORITHM || 'aes-256-ctr';
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
import _ from 'lodash';
|
||||
import buildDebug from 'debug';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { createAnonymousRemoteUser } from '@verdaccio/config';
|
||||
import {
|
||||
API_ERROR,
|
||||
HTTP_STATUS,
|
||||
TOKEN_BASIC,
|
||||
TOKEN_BEARER,
|
||||
VerdaccioError,
|
||||
errorUtils,
|
||||
} from '@verdaccio/core';
|
||||
import {
|
||||
AuthPackageAllow,
|
||||
Callback,
|
||||
Config,
|
||||
IPluginAuth,
|
||||
RemoteUser,
|
||||
Security,
|
||||
AuthPackageAllow,
|
||||
} from '@verdaccio/types';
|
||||
import {
|
||||
HTTP_STATUS,
|
||||
TOKEN_BASIC,
|
||||
TOKEN_BEARER,
|
||||
API_ERROR,
|
||||
VerdaccioError,
|
||||
errorUtils,
|
||||
} from '@verdaccio/core';
|
||||
|
||||
import { createAnonymousRemoteUser } from '@verdaccio/config';
|
||||
import { TokenEncryption, AESPayload } from './auth';
|
||||
import { aesDecrypt } from './legacy-token';
|
||||
import { AESPayload, TokenEncryption } from './auth';
|
||||
import { verifyPayload } from './jwt-token';
|
||||
import { aesDecrypt } from './legacy-token';
|
||||
import { parseBasicPayload } from './token';
|
||||
|
||||
const debug = buildDebug('verdaccio:auth:utils');
|
||||
|
||||
@@ -1,43 +1,42 @@
|
||||
import path from 'path';
|
||||
import _ from 'lodash';
|
||||
import path from 'path';
|
||||
|
||||
import { configExample } from '@verdaccio/mock';
|
||||
import {
|
||||
Config as AppConfig,
|
||||
parseConfigFile,
|
||||
ROLES,
|
||||
createRemoteUser,
|
||||
createAnonymousRemoteUser,
|
||||
createRemoteUser,
|
||||
parseConfigFile,
|
||||
} from '@verdaccio/config';
|
||||
|
||||
import {
|
||||
getAuthenticatedMessage,
|
||||
buildToken,
|
||||
AllowActionCallbackResponse,
|
||||
buildUserBuffer,
|
||||
} from '@verdaccio/utils';
|
||||
|
||||
import { Config, Security, RemoteUser } from '@verdaccio/types';
|
||||
import {
|
||||
VerdaccioError,
|
||||
API_ERROR,
|
||||
CHARACTER_ENCODING,
|
||||
TOKEN_BEARER,
|
||||
API_ERROR,
|
||||
VerdaccioError,
|
||||
errorUtils,
|
||||
} from '@verdaccio/core';
|
||||
import { setup } from '@verdaccio/logger';
|
||||
import { configExample } from '@verdaccio/mock';
|
||||
import { Config, RemoteUser, Security } from '@verdaccio/types';
|
||||
import {
|
||||
AllowActionCallbackResponse,
|
||||
buildToken,
|
||||
buildUserBuffer,
|
||||
getAuthenticatedMessage,
|
||||
} from '@verdaccio/utils';
|
||||
|
||||
import {
|
||||
IAuth,
|
||||
Auth,
|
||||
ActionsAllowed,
|
||||
Auth,
|
||||
IAuth,
|
||||
aesDecrypt,
|
||||
allow_action,
|
||||
getApiToken,
|
||||
getDefaultPlugins,
|
||||
getMiddlewareCredentials,
|
||||
getApiToken,
|
||||
verifyJWTPayload,
|
||||
aesDecrypt,
|
||||
verifyPayload,
|
||||
signPayload,
|
||||
verifyJWTPayload,
|
||||
verifyPayload,
|
||||
} from '../src';
|
||||
|
||||
setup([]);
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
import _ from 'lodash';
|
||||
import { ROLES, Config as AppConfig } from '@verdaccio/config';
|
||||
import { setup } from '@verdaccio/logger';
|
||||
|
||||
import { IAuth } from '@verdaccio/auth';
|
||||
import { Config } from '@verdaccio/types';
|
||||
import { Config as AppConfig, ROLES } from '@verdaccio/config';
|
||||
import { errorUtils } from '@verdaccio/core';
|
||||
import { setup } from '@verdaccio/logger';
|
||||
import { Config } from '@verdaccio/types';
|
||||
|
||||
import { Auth } from '../src';
|
||||
|
||||
import { authProfileConf, authPluginFailureConf, authPluginPassThrougConf } from './helper/plugin';
|
||||
import { authPluginFailureConf, authPluginPassThrougConf, authProfileConf } from './helper/plugin';
|
||||
|
||||
setup([]);
|
||||
|
||||
describe('AuthTest', () => {
|
||||
test('should be defined', () => {
|
||||
const config: Config = new AppConfig(_.cloneDeep(authProfileConf));
|
||||
config.checkSecretKey('12345');
|
||||
|
||||
const auth: IAuth = new Auth(config);
|
||||
|
||||
expect(auth).toBeDefined();
|
||||
@@ -23,6 +25,7 @@ describe('AuthTest', () => {
|
||||
describe('test authenticate states', () => {
|
||||
test('should be a success login', () => {
|
||||
const config: Config = new AppConfig(_.cloneDeep(authProfileConf));
|
||||
config.checkSecretKey('12345');
|
||||
const auth: IAuth = new Auth(config);
|
||||
|
||||
expect(auth).toBeDefined();
|
||||
@@ -49,6 +52,7 @@ describe('AuthTest', () => {
|
||||
|
||||
test('should be a fail on login', () => {
|
||||
const config: Config = new AppConfig(_.cloneDeep(authPluginFailureConf));
|
||||
config.checkSecretKey('12345');
|
||||
const auth: IAuth = new Auth(config);
|
||||
|
||||
expect(auth).toBeDefined();
|
||||
@@ -67,6 +71,7 @@ describe('AuthTest', () => {
|
||||
describe('test authenticate out of control inputs from plugins', () => {
|
||||
test('should skip falsy values', () => {
|
||||
const config: Config = new AppConfig(_.cloneDeep(authPluginPassThrougConf));
|
||||
config.checkSecretKey('12345');
|
||||
const auth: IAuth = new Auth(config);
|
||||
|
||||
expect(auth).toBeDefined();
|
||||
@@ -86,6 +91,7 @@ describe('AuthTest', () => {
|
||||
|
||||
test('should error truthy non-array', () => {
|
||||
const config: Config = new AppConfig(_.cloneDeep(authPluginPassThrougConf));
|
||||
config.checkSecretKey('12345');
|
||||
const auth: IAuth = new Auth(config);
|
||||
|
||||
expect(auth).toBeDefined();
|
||||
@@ -103,6 +109,7 @@ describe('AuthTest', () => {
|
||||
|
||||
test('should skip empty array', () => {
|
||||
const config: Config = new AppConfig(_.cloneDeep(authPluginPassThrougConf));
|
||||
config.checkSecretKey('12345');
|
||||
const auth: IAuth = new Auth(config);
|
||||
|
||||
expect(auth).toBeDefined();
|
||||
@@ -119,6 +126,7 @@ describe('AuthTest', () => {
|
||||
|
||||
test('should accept valid array', () => {
|
||||
const config: Config = new AppConfig(_.cloneDeep(authPluginPassThrougConf));
|
||||
config.checkSecretKey('12345');
|
||||
const auth: IAuth = new Auth(config);
|
||||
|
||||
expect(auth).toBeDefined();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import path from 'path';
|
||||
|
||||
import { configExample as config } from '@verdaccio/mock';
|
||||
|
||||
export const authProfileConf = config({
|
||||
|
||||
@@ -1,5 +1,30 @@
|
||||
# @verdaccio/cli
|
||||
|
||||
## 6.0.0-6-next.25
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [f86c31ed]
|
||||
- Updated dependencies [20c9e43e]
|
||||
- @verdaccio/fastify-migration@6.0.0-6-next.16
|
||||
- @verdaccio/config@6.0.0-6-next.11
|
||||
- @verdaccio/node-api@6.0.0-6-next.24
|
||||
|
||||
## 6.0.0-6-next.24
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 6c1eb021: feat: use warning codes for deprecation warnings
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6c1eb021]
|
||||
- @verdaccio/core@6.0.0-6-next.3
|
||||
- @verdaccio/logger@6.0.0-6-next.7
|
||||
- @verdaccio/node-api@6.0.0-6-next.23
|
||||
- @verdaccio/config@6.0.0-6-next.10
|
||||
- @verdaccio/fastify-migration@6.0.0-6-next.15
|
||||
|
||||
## 6.0.0-6-next.23
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/cli",
|
||||
"version": "6.0.0-6-next.23",
|
||||
"version": "6.0.0-6-next.25",
|
||||
"author": {
|
||||
"name": "Juan Picado",
|
||||
"email": "juanpicado19@gmail.com"
|
||||
@@ -44,11 +44,12 @@
|
||||
"start": "ts-node src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@verdaccio/config": "workspace:6.0.0-6-next.9",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.6",
|
||||
"@verdaccio/node-api": "workspace:6.0.0-6-next.22",
|
||||
"@verdaccio/fastify-migration": "workspace:6.0.0-6-next.14",
|
||||
"clipanion": "3.0.1",
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.3",
|
||||
"@verdaccio/config": "workspace:6.0.0-6-next.11",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.7",
|
||||
"@verdaccio/node-api": "workspace:6.0.0-6-next.24",
|
||||
"@verdaccio/fastify-migration": "workspace:6.0.0-6-next.16",
|
||||
"clipanion": "3.1.0",
|
||||
"envinfo": "7.8.1",
|
||||
"kleur": "3.0.3",
|
||||
"semver": "7.3.5"
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { Cli } from 'clipanion';
|
||||
|
||||
import { warningUtils } from '@verdaccio/core';
|
||||
|
||||
import { FastifyServer } from './commands/FastifyServer';
|
||||
import { InfoCommand } from './commands/info';
|
||||
import { InitCommand } from './commands/init';
|
||||
import { VersionCommand } from './commands/version';
|
||||
import { NewServer } from './commands/newServer';
|
||||
import { isVersionValid, MIN_NODE_VERSION } from './utils';
|
||||
import { MIN_NODE_VERSION, isVersionValid } from './utils';
|
||||
|
||||
if (process.getuid && process.getuid() === 0) {
|
||||
process.emitWarning(`Verdaccio doesn't need superuser privileges. don't run it under root`);
|
||||
warningUtils.emit(warningUtils.Codes.VERWAR001);
|
||||
}
|
||||
|
||||
if (!isVersionValid(process.version)) {
|
||||
@@ -28,7 +30,7 @@ const cli = new Cli({
|
||||
cli.register(InfoCommand);
|
||||
cli.register(InitCommand);
|
||||
cli.register(VersionCommand);
|
||||
cli.register(NewServer);
|
||||
cli.register(FastifyServer);
|
||||
cli.runExit(args, Cli.defaultContext);
|
||||
|
||||
process.on('uncaughtException', function (err) {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Command, Option } from 'clipanion';
|
||||
|
||||
import { findConfigFile, parseConfigFile } from '@verdaccio/config';
|
||||
import { setup, logger } from '@verdaccio/logger';
|
||||
import { warningUtils } from '@verdaccio/core';
|
||||
import server from '@verdaccio/fastify-migration';
|
||||
import { logger, setup } from '@verdaccio/logger';
|
||||
import { ConfigRuntime } from '@verdaccio/types';
|
||||
|
||||
export const DEFAULT_PROCESS_NAME: string = 'verdaccio';
|
||||
@@ -9,9 +11,12 @@ export const DEFAULT_PROCESS_NAME: string = 'verdaccio';
|
||||
/**
|
||||
* This command is intended to run the server with Fastify
|
||||
* as a migration step.
|
||||
* More info: https://github.com/verdaccio/verdaccio/discussions/2155
|
||||
* To try out.
|
||||
* pnpm debug:fastify
|
||||
*/
|
||||
export class NewServer extends Command {
|
||||
public static paths = [['new']];
|
||||
export class FastifyServer extends Command {
|
||||
public static paths = [['fastify-server']];
|
||||
|
||||
private port = Option.String('-l,-p,--listen,--port', {
|
||||
description: 'host:port number to listen on (default: localhost:4873)',
|
||||
@@ -24,7 +29,7 @@ export class NewServer extends Command {
|
||||
private initLogger(logConfig: ConfigRuntime) {
|
||||
try {
|
||||
if (logConfig.logs) {
|
||||
process.emitWarning('config.logs is deprecated, rename configuration to "config.log"');
|
||||
warningUtils.emit(warningUtils.Codes.VERDEP001);
|
||||
}
|
||||
// FUTURE: remove fallback when is ready
|
||||
setup(logConfig.log || logConfig.logs);
|
||||
@@ -41,9 +46,11 @@ export class NewServer extends Command {
|
||||
this.initLogger(configParsed);
|
||||
|
||||
process.title = web?.title || DEFAULT_PROCESS_NAME;
|
||||
// FIXME: need a way to get version of the package.
|
||||
// const { version, name } = require('../../package.json');
|
||||
const ser = await server({ logger, config: configParsed });
|
||||
await ser.listen(4873);
|
||||
// FIXME: harcoded, this would need to come from the configuration and the --listen flag.
|
||||
await ser.listen(process.env.PORT || 4873);
|
||||
} catch (err: any) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
@@ -1,5 +1,5 @@
|
||||
import envinfo from 'envinfo';
|
||||
import { Command } from 'clipanion';
|
||||
import envinfo from 'envinfo';
|
||||
|
||||
export class InfoCommand extends Command {
|
||||
public static paths = [[`--info`], [`-i`]];
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { Command, Option } from 'clipanion';
|
||||
|
||||
import { findConfigFile, parseConfigFile } from '@verdaccio/config';
|
||||
import { setup, logger } from '@verdaccio/logger';
|
||||
import { warningUtils } from '@verdaccio/core';
|
||||
import { logger, setup } from '@verdaccio/logger';
|
||||
import { initServer } from '@verdaccio/node-api';
|
||||
import { ConfigRuntime } from '@verdaccio/types';
|
||||
|
||||
@@ -46,9 +48,7 @@ export class InitCommand extends Command {
|
||||
private initLogger(logConfig: ConfigRuntime) {
|
||||
try {
|
||||
if (logConfig.logs) {
|
||||
process.emitWarning(
|
||||
'config.logs is deprecated, rename configuration to "config.log" in singular'
|
||||
);
|
||||
warningUtils.emit(warningUtils.Codes.VERDEP001);
|
||||
}
|
||||
// FUTURE: remove fallback when is ready
|
||||
setup(logConfig.log || logConfig.logs);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import semver from 'semver';
|
||||
|
||||
export const MIN_NODE_VERSION = '14';
|
||||
export const MIN_NODE_VERSION = '14.0.0';
|
||||
|
||||
export function isVersionValid(version) {
|
||||
export function isVersionValid(processVersion) {
|
||||
const version = processVersion.substr(1);
|
||||
return semver.satisfies(version, `>=${MIN_NODE_VERSION}`);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import { isVersionValid } from '../src/utils';
|
||||
|
||||
test('valid version node.js', () => {
|
||||
expect(isVersionValid('14.0.0')).toBeTruthy();
|
||||
expect(isVersionValid('v14.0.0')).toBeTruthy();
|
||||
expect(isVersionValid('v15.0.0')).toBeTruthy();
|
||||
expect(isVersionValid('v16.0.0')).toBeTruthy();
|
||||
expect(isVersionValid('v17.0.0')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('is invalid version node.js', () => {
|
||||
expect(isVersionValid('13.0.0')).toBeFalsy();
|
||||
expect(isVersionValid('v13.0.0')).toBeFalsy();
|
||||
expect(isVersionValid('v12.0.0')).toBeFalsy();
|
||||
expect(isVersionValid('v8.0.0')).toBeFalsy();
|
||||
expect(isVersionValid('v4.0.0')).toBeFalsy();
|
||||
expect(isVersionValid('v0.0.10')).toBeFalsy();
|
||||
});
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
{
|
||||
"path": "../core/cli-ui"
|
||||
},
|
||||
{
|
||||
"path": "../core/core"
|
||||
},
|
||||
{
|
||||
"path": "../core/server"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# @verdaccio/config
|
||||
|
||||
## 6.0.0-6-next.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [f86c31ed]
|
||||
- @verdaccio/utils@6.0.0-6-next.9
|
||||
|
||||
## 6.0.0-6-next.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6c1eb021]
|
||||
- @verdaccio/core@6.0.0-6-next.3
|
||||
- @verdaccio/utils@6.0.0-6-next.8
|
||||
|
||||
## 6.0.0-6-next.9
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/config",
|
||||
"version": "6.0.0-6-next.9",
|
||||
"version": "6.0.0-6-next.11",
|
||||
"description": "logger",
|
||||
"main": "./build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
@@ -39,13 +39,13 @@
|
||||
"build": "pnpm run build:js && pnpm run build:types"
|
||||
},
|
||||
"dependencies": {
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.2",
|
||||
"@verdaccio/utils": "workspace:6.0.0-6-next.7",
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.3",
|
||||
"@verdaccio/utils": "workspace:6.0.0-6-next.9",
|
||||
"debug": "4.3.2",
|
||||
"js-yaml": "3.14.1",
|
||||
"lodash": "4.17.21",
|
||||
"minimatch": "3.0.4",
|
||||
"yup": "0.32.9"
|
||||
"yup": "0.32.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/minimatch": "3.0.5",
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import _ from 'lodash';
|
||||
import buildDebug from 'debug';
|
||||
import fs from 'fs';
|
||||
import _ from 'lodash';
|
||||
import path from 'path';
|
||||
|
||||
import { CHARACTER_ENCODING } from '@verdaccio/core';
|
||||
import { folderExists, fileExists } from './config-utils';
|
||||
|
||||
import { fileExists, folderExists } from './config-utils';
|
||||
|
||||
const CONFIG_FILE = 'config.yaml';
|
||||
const XDG = 'xdg';
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
import assert from 'assert';
|
||||
import _ from 'lodash';
|
||||
import buildDebug from 'debug';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { getMatchedPackagesSpec, generateRandomHexString, isObject } from '@verdaccio/utils';
|
||||
import { APP_ERROR } from '@verdaccio/core';
|
||||
import {
|
||||
PackageList,
|
||||
Config as AppConfig,
|
||||
ConfigRuntime,
|
||||
Security,
|
||||
PackageAccess,
|
||||
ServerSettingsConf,
|
||||
AuthConf,
|
||||
ConfigRuntime,
|
||||
PackageAccess,
|
||||
PackageList,
|
||||
Security,
|
||||
ServerSettingsConf,
|
||||
} from '@verdaccio/types';
|
||||
import { generateRandomHexString, getMatchedPackagesSpec, isObject } from '@verdaccio/utils';
|
||||
|
||||
import { generateRandomSecretKey } from './token';
|
||||
import { normalisePackageAccess } from './package-access';
|
||||
import { sanityCheckUplinksProps, uplinkSanityCheck } from './uplinks';
|
||||
import { defaultSecurity } from './security';
|
||||
import { getUserAgent } from './agent';
|
||||
import { normalisePackageAccess } from './package-access';
|
||||
import { defaultSecurity } from './security';
|
||||
import serverSettings from './serverSettings';
|
||||
import { generateRandomSecretKey } from './token';
|
||||
import { sanityCheckUplinksProps, uplinkSanityCheck } from './uplinks';
|
||||
|
||||
const strategicConfigProps = ['uplinks', 'packages'];
|
||||
const allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import assert from 'assert';
|
||||
import _ from 'lodash';
|
||||
import { PackageAccess } from '@verdaccio/types';
|
||||
|
||||
import { errorUtils } from '@verdaccio/core';
|
||||
import { PackageAccess } from '@verdaccio/types';
|
||||
|
||||
export interface LegacyPackageList {
|
||||
[key: string]: PackageAccess;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import fs from 'fs';
|
||||
import YAML from 'js-yaml';
|
||||
|
||||
import { APP_ERROR } from '@verdaccio/core';
|
||||
import { ConfigRuntime, ConfigYaml } from '@verdaccio/types';
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import assert from 'assert';
|
||||
import { getMatchedPackagesSpec } from '@verdaccio/utils';
|
||||
import { PackageList, UpLinksConfList } from '@verdaccio/types';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { PackageList, UpLinksConfList } from '@verdaccio/types';
|
||||
import { getMatchedPackagesSpec } from '@verdaccio/utils';
|
||||
|
||||
export const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
||||
export const DEFAULT_UPLINK = 'npmjs';
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os from 'os';
|
||||
|
||||
import { findConfigFile } from '../src/config-path';
|
||||
|
||||
const mockmkDir = jest.fn();
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import path from 'path';
|
||||
import _ from 'lodash';
|
||||
import path from 'path';
|
||||
|
||||
import {
|
||||
Config,
|
||||
DEFAULT_REGISTRY,
|
||||
DEFAULT_UPLINK,
|
||||
defaultSecurity,
|
||||
parseConfigFile,
|
||||
ROLES,
|
||||
WEB_TITLE,
|
||||
defaultSecurity,
|
||||
parseConfigFile,
|
||||
} from '../src';
|
||||
import { parseConfigurationFile } from './utils';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
import { normalisePackageAccess, PACKAGE_ACCESS } from '../src/package-access';
|
||||
import { parseConfigFile } from '../src';
|
||||
import { PACKAGE_ACCESS, normalisePackageAccess } from '../src/package-access';
|
||||
import { parseConfigurationFile } from './utils';
|
||||
|
||||
describe('Package access utilities', () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { generateRandomSecretKey, TOKEN_VALID_LENGTH } from '../src/token';
|
||||
import { TOKEN_VALID_LENGTH, generateRandomSecretKey } from '../src/token';
|
||||
|
||||
test('token test valid length', () => {
|
||||
const token = generateRandomSecretKey();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { hasProxyTo, sanityCheckUplinksProps, uplinkSanityCheck } from '../src/uplinks';
|
||||
import { normalisePackageAccess, parseConfigFile } from '../src';
|
||||
import { hasProxyTo, sanityCheckUplinksProps, uplinkSanityCheck } from '../src/uplinks';
|
||||
import { parseConfigurationFile } from './utils';
|
||||
|
||||
describe('Uplinks Utilities', () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ROLES, createAnonymousRemoteUser, createRemoteUser } from '../src';
|
||||
import { spliceURL } from '../src/string';
|
||||
import { createAnonymousRemoteUser, createRemoteUser, ROLES } from '../src';
|
||||
|
||||
describe('spliceURL', () => {
|
||||
test('should splice two strings and generate a url', () => {
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @verdaccio/core
|
||||
|
||||
## 6.0.0-6-next.3
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 6c1eb021: feat: use warning codes for deprecation warnings
|
||||
|
||||
## 6.0.0-6-next.2
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/core",
|
||||
"version": "6.0.0-6-next.2",
|
||||
"version": "6.0.0-6-next.3",
|
||||
"description": "core utilities",
|
||||
"keywords": [
|
||||
"private",
|
||||
@@ -36,7 +36,8 @@
|
||||
"dependencies": {
|
||||
"http-errors": "1.8.0",
|
||||
"http-status-codes": "2.1.4",
|
||||
"semver": "7.3.5"
|
||||
"semver": "7.3.5",
|
||||
"fastify-warning": "0.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@verdaccio/types": "workspace:11.0.0-6-next.9"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import createError, { HttpError } from 'http-errors';
|
||||
|
||||
import { DEFAULT_MIN_LIMIT_PASSWORD, HTTP_STATUS } from './constants';
|
||||
|
||||
export const API_ERROR = {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import * as searchUtils from './search-utils';
|
||||
import * as streamUtils from './stream-utils';
|
||||
import * as errorUtils from './error-utils';
|
||||
import * as validatioUtils from './validation-utils';
|
||||
import * as constants from './constants';
|
||||
import * as pluginUtils from './plugin-utils';
|
||||
import * as errorUtils from './error-utils';
|
||||
import * as fileUtils from './file-utils';
|
||||
import * as pkgUtils from './pkg-utils';
|
||||
import * as pluginUtils from './plugin-utils';
|
||||
import * as searchUtils from './search-utils';
|
||||
import * as streamUtils from './stream-utils';
|
||||
import * as validatioUtils from './validation-utils';
|
||||
import * as warningUtils from './warning-utils';
|
||||
|
||||
export { VerdaccioError, API_ERROR, SUPPORT_ERRORS, APP_ERROR } from './error-utils';
|
||||
export {
|
||||
@@ -32,4 +33,5 @@ export {
|
||||
validatioUtils,
|
||||
constants,
|
||||
pluginUtils,
|
||||
warningUtils,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Package } from '@verdaccio/types';
|
||||
import semver from 'semver';
|
||||
|
||||
import { Package } from '@verdaccio/types';
|
||||
|
||||
import { DIST_TAGS } from './constants';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Config, IPackageStorage, Token, TokenFilter } from '@verdaccio/types';
|
||||
|
||||
import { searchUtils } from '.';
|
||||
|
||||
interface IPlugin {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PassThrough, TransformOptions, Transform } from 'stream';
|
||||
import { PassThrough, Transform, TransformOptions } from 'stream';
|
||||
|
||||
export interface IReadTarball {
|
||||
abort?: () => void;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import assert from 'assert';
|
||||
|
||||
import { Package } from '@verdaccio/types';
|
||||
|
||||
import { DIST_TAGS } from './constants';
|
||||
|
||||
export function isPackageNameScoped(name: string): boolean {
|
||||
|
||||
59
packages/core/core/src/warning-utils.ts
Normal file
59
packages/core/core/src/warning-utils.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import warning from 'fastify-warning';
|
||||
|
||||
const warningInstance = warning();
|
||||
const verdaccioWarning = 'VerdaccioWarning';
|
||||
const verdaccioDeprecation = 'VerdaccioDeprecation';
|
||||
|
||||
export enum Codes {
|
||||
VERWAR001 = 'VERWAR001',
|
||||
VERWAR002 = 'VERWAR002',
|
||||
VERWAR003 = 'VERWAR003',
|
||||
VERWAR004 = 'VERWAR004',
|
||||
VERDEP001 = 'VERDEP001',
|
||||
VERDEP002 = 'VERDEP002',
|
||||
VERDEP003 = 'VERDEP003',
|
||||
}
|
||||
|
||||
warningInstance.create(
|
||||
verdaccioWarning,
|
||||
Codes.VERWAR001,
|
||||
`Verdaccio doesn't need superuser privileges. don't run it under root`
|
||||
);
|
||||
|
||||
warningInstance.create(verdaccioWarning, Codes.VERWAR002, 'logger is not defined');
|
||||
|
||||
warningInstance.create(
|
||||
verdaccioWarning,
|
||||
Codes.VERWAR003,
|
||||
'rotating-file type is not longer supported, consider use [logrotate] instead'
|
||||
);
|
||||
|
||||
warningInstance.create(
|
||||
verdaccioWarning,
|
||||
Codes.VERWAR004,
|
||||
`invalid address - %s, we expect a port (e.g. "4873"),
|
||||
host:port (e.g. "localhost:4873") or full url '(e.g. "http://localhost:4873/")
|
||||
https://verdaccio.org/docs/en/configuration#listen-port`
|
||||
);
|
||||
|
||||
warningInstance.create(
|
||||
verdaccioDeprecation,
|
||||
Codes.VERDEP001,
|
||||
'config.logs is deprecated, rename configuration to "config.log" in singular'
|
||||
);
|
||||
|
||||
warningInstance.create(
|
||||
verdaccioDeprecation,
|
||||
Codes.VERDEP002,
|
||||
'deprecate: multiple logger configuration is deprecated, please check the migration guide.'
|
||||
);
|
||||
|
||||
warningInstance.create(
|
||||
verdaccioDeprecation,
|
||||
Codes.VERDEP003,
|
||||
'multiple addresses will be deprecated in the next major, only use one'
|
||||
);
|
||||
|
||||
export function emit(code, a?: string, b?: string, c?: string) {
|
||||
warningInstance.emit(code, a, b, c);
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
import _ from 'lodash';
|
||||
import { HTTP_STATUS } from '../src/constants';
|
||||
|
||||
import { HTTP_STATUS } from '../src/constants';
|
||||
import {
|
||||
getNotFound,
|
||||
VerdaccioError,
|
||||
getConflict,
|
||||
getBadData,
|
||||
getInternalError,
|
||||
API_ERROR,
|
||||
getUnauthorized,
|
||||
getForbidden,
|
||||
getServiceUnavailable,
|
||||
VerdaccioError,
|
||||
getBadData,
|
||||
getCode,
|
||||
getConflict,
|
||||
getForbidden,
|
||||
getInternalError,
|
||||
getNotFound,
|
||||
getServiceUnavailable,
|
||||
getUnauthorized,
|
||||
} from '../src/error-utils';
|
||||
|
||||
describe('testing errors', () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { semverSort, mergeVersions } from '../src/pkg-utils';
|
||||
import { mergeVersions, semverSort } from '../src/pkg-utils';
|
||||
|
||||
describe('Storage._merge_versions versions', () => {
|
||||
test('simple', () => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Stream } from 'stream';
|
||||
import { readableToString, ReadTarball, UploadTarball } from '../src/stream-utils';
|
||||
|
||||
import { ReadTarball, UploadTarball, readableToString } from '../src/stream-utils';
|
||||
|
||||
describe('mystreams', () => {
|
||||
test('should delay events on ReadTarball abort', (cb) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { validateName, validatePackage, isObject } from '../src/validation-utils';
|
||||
import { isObject, validateName, validatePackage } from '../src/validation-utils';
|
||||
|
||||
describe('validatePackage', () => {
|
||||
test('should validate package names', () => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import locker from 'lockfile';
|
||||
|
||||
import { Callback } from '@verdaccio/types';
|
||||
|
||||
// unlocks file by removing existing lock file
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import locker from 'lockfile';
|
||||
import path from 'path';
|
||||
|
||||
export const statDir = (name: string): Promise<Error | null> => {
|
||||
return new Promise((resolve, reject): void => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { lockFile, unlockFile, readFile } from '../src/index';
|
||||
import { lockFile, readFile, unlockFile } from '../src/index';
|
||||
|
||||
interface Error {
|
||||
message: string;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -40,9 +40,9 @@
|
||||
"build"
|
||||
],
|
||||
"dependencies": {
|
||||
"dompurify": "2.3.1",
|
||||
"dompurify": "2.3.3",
|
||||
"jsdom": "17.0.0",
|
||||
"marked": "3.0.2"
|
||||
"marked": "3.0.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@verdaccio/types": "workspace:11.0.0-6-next.9"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import marked from 'marked';
|
||||
import createDOMPurify from 'dompurify';
|
||||
import { JSDOM } from 'jsdom';
|
||||
import marked from 'marked';
|
||||
|
||||
const DOMPurify = createDOMPurify(new JSDOM('').window);
|
||||
|
||||
|
||||
@@ -1,5 +1,38 @@
|
||||
# @verdaccio/fastify-migration
|
||||
|
||||
## 6.0.0-6-next.16
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- f86c31ed: feat: migrate web sidebar endpoint to fastify
|
||||
|
||||
reuse utils methods between packages
|
||||
|
||||
- 20c9e43e: dist tags Implementation on Fastify
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [f86c31ed]
|
||||
- Updated dependencies [20c9e43e]
|
||||
- @verdaccio/store@6.0.0-6-next.16
|
||||
- @verdaccio/utils@6.0.0-6-next.9
|
||||
- @verdaccio/auth@6.0.0-6-next.15
|
||||
- @verdaccio/config@6.0.0-6-next.11
|
||||
- @verdaccio/tarball@11.0.0-6-next.10
|
||||
|
||||
## 6.0.0-6-next.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6c1eb021]
|
||||
- @verdaccio/core@6.0.0-6-next.3
|
||||
- @verdaccio/logger@6.0.0-6-next.7
|
||||
- @verdaccio/auth@6.0.0-6-next.14
|
||||
- @verdaccio/config@6.0.0-6-next.10
|
||||
- @verdaccio/tarball@11.0.0-6-next.9
|
||||
- @verdaccio/store@6.0.0-6-next.15
|
||||
- @verdaccio/utils@6.0.0-6-next.8
|
||||
|
||||
## 6.0.0-6-next.14
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import path from 'path';
|
||||
import buildDebug from 'debug';
|
||||
import path from 'path';
|
||||
|
||||
import { parseConfigFile } from '@verdaccio/config';
|
||||
import { setup, logger } from '@verdaccio/logger';
|
||||
import { logger, setup } from '@verdaccio/logger';
|
||||
|
||||
import server from '../src/index';
|
||||
|
||||
const debug = buildDebug('verdaccio:fastify:debug');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/fastify-migration",
|
||||
"version": "6.0.0-6-next.14",
|
||||
"version": "6.0.0-6-next.16",
|
||||
"description": "Fastify server migration package",
|
||||
"keywords": [
|
||||
"private",
|
||||
@@ -34,19 +34,24 @@
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"@verdaccio/config": "workspace:6.0.0-6-next.9",
|
||||
"@verdaccio/auth": "workspace:6.0.0-6-next.13",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.6",
|
||||
"@verdaccio/store": "workspace:6.0.0-6-next.14",
|
||||
"@verdaccio/core": "workspace:6.0.0-6-next.3",
|
||||
"@verdaccio/config": "workspace:6.0.0-6-next.11",
|
||||
"@verdaccio/auth": "workspace:6.0.0-6-next.15",
|
||||
"@verdaccio/logger": "workspace:6.0.0-6-next.7",
|
||||
"@verdaccio/store": "workspace:6.0.0-6-next.16",
|
||||
"@verdaccio/tarball": "workspace:11.0.0-6-next.10",
|
||||
"@verdaccio/utils": "workspace:6.0.0-6-next.9",
|
||||
"@verdaccio/readme": "workspace:11.0.0-6-next.4",
|
||||
"abortcontroller-polyfill": "1.7.3",
|
||||
"core-js": "3.17.2",
|
||||
"debug": "4.3.2",
|
||||
"fastify": "3.20.2",
|
||||
"fastify": "3.22.1",
|
||||
"fastify-plugin": "3.0.0",
|
||||
"lodash": "4.17.21",
|
||||
"semver": "7.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "16.9.1",
|
||||
"@types/node": "16.11.6",
|
||||
"@verdaccio/types": "workspace:11.0.0-6-next.9",
|
||||
"ts-node": "10.2.1"
|
||||
},
|
||||
|
||||
55
packages/core/server/src/endpoints/dist-tags.ts
Normal file
55
packages/core/server/src/endpoints/dist-tags.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import buildDebug from 'debug';
|
||||
import { FastifyInstance } from 'fastify';
|
||||
|
||||
const debug = buildDebug('verdaccio:api:dist-tags');
|
||||
|
||||
async function distTagsRoute(fastify: FastifyInstance) {
|
||||
fastify.get('/-/package/:packageName/dist-tags', async (request, reply) => {
|
||||
// @ts-ignore
|
||||
const { packageName } = request.params;
|
||||
debug('dist-tags: response %o', packageName);
|
||||
fastify.storage.getPackage({
|
||||
name: packageName,
|
||||
uplinksLook: true,
|
||||
req: request.raw,
|
||||
callback: function (err, info): void {
|
||||
if (err) {
|
||||
reply.send(err);
|
||||
}
|
||||
reply.code(fastify.statusCode.OK).send(info[fastify.constants.DIST_TAGS]);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
fastify.post('/-/package/:packageName/dist-tags', async (request, reply) => {
|
||||
// @ts-ignore
|
||||
const { packageName } = request.params;
|
||||
// @ts-ignore
|
||||
fastify.storage.mergeTags(packageName, request.body, function (err): void {
|
||||
if (err) {
|
||||
reply.send(err);
|
||||
}
|
||||
reply
|
||||
.code(fastify.statusCode.CREATED)
|
||||
.send({ ok: fastify.constants.API_MESSAGE.TAG_UPDATED });
|
||||
});
|
||||
});
|
||||
|
||||
fastify.delete('/-/package/:packageName/dist-tags', async (request, reply) => {
|
||||
// @ts-ignore
|
||||
const { packageName } = request.params;
|
||||
fastify.storage.getPackage({
|
||||
name: packageName,
|
||||
uplinksLook: true,
|
||||
req: request.raw,
|
||||
callback: function (err, info): void {
|
||||
if (err) {
|
||||
reply.send(err);
|
||||
}
|
||||
reply.send(info[fastify.constants.DIST_TAGS]);
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default distTagsRoute;
|
||||
@@ -1,13 +1,15 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
/* eslint-disable no-invalid-this */
|
||||
import { FastifyInstance } from 'fastify';
|
||||
|
||||
import { logger } from '@verdaccio/logger';
|
||||
|
||||
async function pingRoute(fastify) {
|
||||
async function pingRoute(fastify: FastifyInstance) {
|
||||
fastify.get('/-/ping', async () => {
|
||||
logger.http('ping endpoint');
|
||||
// @ts-ignore
|
||||
console.log('-storage->', fastify.storage);
|
||||
console.log('-config->', fastify.config);
|
||||
console.log('-config->', fastify.configInstance);
|
||||
return {};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
/* eslint-disable no-invalid-this */
|
||||
import { FastifyInstance } from 'fastify';
|
||||
|
||||
import { logger } from '@verdaccio/logger';
|
||||
|
||||
async function searchRoute(fastify) {
|
||||
async function searchRoute(fastify: FastifyInstance) {
|
||||
fastify.get('/-/v1/search', async (request, reply) => {
|
||||
// TODO: apply security layer here like in
|
||||
// packages/api/src/v1/search.ts
|
||||
@@ -10,11 +13,11 @@ async function searchRoute(fastify) {
|
||||
// TODO: review which query fields are mandatory
|
||||
|
||||
const abort = new AbortController();
|
||||
|
||||
request.on('aborted', () => {
|
||||
request.socket.on('aborted', () => {
|
||||
abort.abort();
|
||||
});
|
||||
const { url, query } = request;
|
||||
// @ts-ignore
|
||||
const { url, query } = request.query;
|
||||
const storage = fastify.storage;
|
||||
|
||||
const data = await storage.searchManager?.search({
|
||||
|
||||
24
packages/core/server/src/endpoints/tarball.ts
Normal file
24
packages/core/server/src/endpoints/tarball.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import buildDebug from 'debug';
|
||||
import { FastifyInstance } from 'fastify';
|
||||
|
||||
const debug = buildDebug('verdaccio:api:tarball');
|
||||
|
||||
async function tarballRoute(fastify: FastifyInstance) {
|
||||
fastify.get('/:package/-/:filename', async (request, reply) => {
|
||||
// @ts-ignore
|
||||
const { package: pkg, filename } = request.params;
|
||||
debug('stream tarball for %s@%s', pkg, filename);
|
||||
const stream = fastify.storage.getTarball(pkg, filename);
|
||||
return reply.send(stream);
|
||||
});
|
||||
|
||||
fastify.get('/:scopedPackage/-/:scope/:filename', async (request, reply) => {
|
||||
// @ts-ignore
|
||||
const { scopedPackage, filename } = request.params;
|
||||
debug('stream scope tarball for %s@%s', scopedPackage, filename);
|
||||
const stream = fastify.storage.getTarball(scopedPackage, filename);
|
||||
return reply.send(stream);
|
||||
});
|
||||
}
|
||||
|
||||
export default tarballRoute;
|
||||
132
packages/core/server/src/endpoints/user.ts
Normal file
132
packages/core/server/src/endpoints/user.ts
Normal file
@@ -0,0 +1,132 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
/* eslint-disable no-invalid-this */
|
||||
import buildDebug from 'debug';
|
||||
import { FastifyInstance, FastifyRequest } from 'fastify';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { getApiToken } from '@verdaccio/auth';
|
||||
import { createRemoteUser } from '@verdaccio/config';
|
||||
import { logger } from '@verdaccio/logger';
|
||||
import { RemoteUser } from '@verdaccio/types';
|
||||
import { getAuthenticatedMessage, validatePassword } from '@verdaccio/utils';
|
||||
|
||||
const debug = buildDebug('verdaccio:api:user');
|
||||
|
||||
async function userRoute(fastify: FastifyInstance) {
|
||||
fastify.get('/:org_couchdb_user', async (request, reply) => {
|
||||
// @ts-expect-error
|
||||
const message = getAuthenticatedMessage(request.userRemote.name);
|
||||
logger.info('user authenticated message %o', message);
|
||||
reply.code(fastify.statusCode.OK);
|
||||
return { ok: message };
|
||||
});
|
||||
|
||||
fastify.delete('/token/:token', async (request: FastifyRequest, reply) => {
|
||||
debug('loging out');
|
||||
// FIXME: type params correctly
|
||||
// @ts-ignore
|
||||
const { token } = request.params;
|
||||
const userRemote: RemoteUser = request.userRemote;
|
||||
await fastify.auth.invalidateToken(token);
|
||||
console.log('userRoute', userRemote);
|
||||
reply.code(fastify.statusCode.OK);
|
||||
return { ok: fastify.apiMessage.LOGGED_OUT };
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
fastify.put<{
|
||||
Body: { name: string; password: string };
|
||||
}>('/:username', async (request, reply) => {
|
||||
const { name, password } = request.body;
|
||||
const remoteName = request.userRemote.name;
|
||||
if (_.isNil(remoteName) === false && _.isNil(name) === false && remoteName === name) {
|
||||
// debug('login: no remote user detected');
|
||||
fastify.auth.authenticate(
|
||||
name,
|
||||
password,
|
||||
async function callbackAuthenticate(err, user): Promise<void> {
|
||||
if (err) {
|
||||
logger.trace(
|
||||
{ name, err },
|
||||
'authenticating for user @{username} failed. Error: @{err.message}'
|
||||
);
|
||||
reply
|
||||
.code(fastify.statusCode.UNAUTHORIZED)
|
||||
.send(
|
||||
fastify.errorUtils.getCode(
|
||||
fastify.statusCode.UNAUTHORIZED,
|
||||
fastify.apiError.BAD_USERNAME_PASSWORD
|
||||
)
|
||||
);
|
||||
}
|
||||
const restoredRemoteUser: RemoteUser = createRemoteUser(name, user.groups || []);
|
||||
const token = await getApiToken(
|
||||
fastify.auth,
|
||||
fastify.configInstance,
|
||||
restoredRemoteUser,
|
||||
password
|
||||
);
|
||||
debug('login: new token');
|
||||
if (!token) {
|
||||
return reply.send(fastify.errorUtils.getUnauthorized());
|
||||
} else {
|
||||
reply.code(fastify.statusCode.CREATED);
|
||||
const message = getAuthenticatedMessage(remoteName);
|
||||
debug('login: created user message %o', message);
|
||||
reply.send({
|
||||
ok: message,
|
||||
token,
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
if (validatePassword(password) === false) {
|
||||
debug('adduser: invalid password');
|
||||
reply.code(fastify.statusCode.BAD_REQUEST).send(
|
||||
fastify.errorUtils.getCode(
|
||||
fastify.statusCode.BAD_REQUEST,
|
||||
// eslint-disable-next-line new-cap
|
||||
fastify.apiError.PASSWORD_SHORT()
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
fastify.auth.add_user(name, password, async function (err, user): Promise<void> {
|
||||
if (err) {
|
||||
if (
|
||||
err.status >= fastify.statusCode.BAD_REQUEST &&
|
||||
err.status < fastify.statusCode.INTERNAL_ERROR
|
||||
) {
|
||||
debug('adduser: error on create user');
|
||||
// With npm registering is the same as logging in,
|
||||
// and npm accepts only an 409 error.
|
||||
// So, changing status code here.
|
||||
const addUserError =
|
||||
fastify.errorUtils.getCode(err.status, err.message) ||
|
||||
fastify.errorUtils.getConflict(err.message);
|
||||
|
||||
reply.send(addUserError);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const token =
|
||||
name && password
|
||||
? await getApiToken(fastify.auth, fastify.configInstance, user, password)
|
||||
: undefined;
|
||||
debug('adduser: new token %o', token);
|
||||
if (!token) {
|
||||
return reply.send(fastify.errorUtils.getUnauthorized());
|
||||
}
|
||||
debug('adduser: user has been created');
|
||||
reply.code(fastify.statusCode.CREATED).send({
|
||||
ok: `user '${name}' created`,
|
||||
token,
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default userRoute;
|
||||
15
packages/core/server/src/endpoints/whoami.ts
Normal file
15
packages/core/server/src/endpoints/whoami.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import buildDebug from 'debug';
|
||||
import { FastifyInstance } from 'fastify';
|
||||
|
||||
const debug = buildDebug('verdaccio:api:whoami');
|
||||
|
||||
async function whoamiRoute(fastify: FastifyInstance) {
|
||||
fastify.get('/-/whoami', async (request, reply) => {
|
||||
const username: string | void = request.userRemote.name;
|
||||
debug('whoami: response %o', username);
|
||||
reply.code(fastify.statusCode.OK);
|
||||
return { username };
|
||||
});
|
||||
}
|
||||
|
||||
export default whoamiRoute;
|
||||
@@ -1,5 +1,6 @@
|
||||
import semver from 'semver';
|
||||
|
||||
// FUTURE: remove when v15 is the minimum requirement
|
||||
if (semver.lte(process.version, 'v15.0.0')) {
|
||||
global.AbortController = require('abortcontroller-polyfill/dist/cjs-ponyfill').AbortController;
|
||||
}
|
||||
|
||||
22
packages/core/server/src/plugins/auth.ts
Normal file
22
packages/core/server/src/plugins/auth.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { FastifyInstance } from 'fastify';
|
||||
import fp from 'fastify-plugin';
|
||||
|
||||
import { Auth, IAuth } from '@verdaccio/auth';
|
||||
import { Config as IConfig } from '@verdaccio/types';
|
||||
|
||||
export default fp(
|
||||
async function (fastify: FastifyInstance, opts: { config: IConfig; filters?: unknown }) {
|
||||
const { config } = opts;
|
||||
const auth: IAuth = new Auth(config);
|
||||
fastify.decorate('auth', auth);
|
||||
},
|
||||
{
|
||||
fastify: '>=3.x',
|
||||
}
|
||||
);
|
||||
|
||||
declare module 'fastify' {
|
||||
interface FastifyInstance {
|
||||
auth: IAuth;
|
||||
}
|
||||
}
|
||||
22
packages/core/server/src/plugins/config.ts
Normal file
22
packages/core/server/src/plugins/config.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { FastifyInstance } from 'fastify';
|
||||
import fp from 'fastify-plugin';
|
||||
|
||||
import { Config as AppConfig } from '@verdaccio/config';
|
||||
import { ConfigRuntime, Config as IConfig } from '@verdaccio/types';
|
||||
|
||||
export default fp(
|
||||
async function (fastify: FastifyInstance, opts: { config: ConfigRuntime }) {
|
||||
const { config } = opts;
|
||||
const configInstance: IConfig = new AppConfig(Object.assign({}, config));
|
||||
fastify.decorate('configInstance', configInstance);
|
||||
},
|
||||
{
|
||||
fastify: '>=3.x',
|
||||
}
|
||||
);
|
||||
|
||||
declare module 'fastify' {
|
||||
interface FastifyInstance {
|
||||
configInstance: IConfig;
|
||||
}
|
||||
}
|
||||
34
packages/core/server/src/plugins/coreUtils.ts
Normal file
34
packages/core/server/src/plugins/coreUtils.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import fp from 'fastify-plugin';
|
||||
|
||||
import {
|
||||
API_ERROR,
|
||||
API_MESSAGE,
|
||||
HTTP_STATUS,
|
||||
constants,
|
||||
errorUtils,
|
||||
validatioUtils,
|
||||
} from '@verdaccio/core';
|
||||
|
||||
export default fp(
|
||||
async function (fastify) {
|
||||
fastify.decorate('errorUtils', errorUtils);
|
||||
fastify.decorate('apiError', API_ERROR);
|
||||
fastify.decorate('constants', constants);
|
||||
fastify.decorate('apiMessage', API_MESSAGE);
|
||||
fastify.decorate('validatioUtils', validatioUtils);
|
||||
fastify.decorate('statusCode', HTTP_STATUS);
|
||||
},
|
||||
{
|
||||
fastify: '>=3.x',
|
||||
}
|
||||
);
|
||||
|
||||
declare module 'fastify' {
|
||||
interface FastifyInstance {
|
||||
apiError: typeof API_ERROR;
|
||||
apiMessage: typeof API_MESSAGE;
|
||||
statusCode: typeof HTTP_STATUS;
|
||||
errorUtils: typeof errorUtils;
|
||||
constants: typeof constants;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,24 @@
|
||||
import { Storage } from '@verdaccio/store';
|
||||
import { FastifyInstance } from 'fastify';
|
||||
import fp from 'fastify-plugin';
|
||||
|
||||
export async function storageService(fastify, opts, done) {
|
||||
const { config, filters } = opts;
|
||||
// @ts-ignore
|
||||
const storage: Storage = new Storage(config);
|
||||
await storage.init(config, filters ?? {});
|
||||
fastify.decorate('storage', storage);
|
||||
done();
|
||||
import { Storage } from '@verdaccio/store';
|
||||
import { Config as IConfig } from '@verdaccio/types';
|
||||
|
||||
export default fp(
|
||||
async function (fastify: FastifyInstance, opts: { config: IConfig; filters?: unknown }) {
|
||||
const { config } = opts;
|
||||
const storage: Storage = new Storage(config);
|
||||
// @ts-ignore
|
||||
await storage.init(config, {});
|
||||
fastify.decorate('storage', storage);
|
||||
},
|
||||
{
|
||||
fastify: '>=3.x',
|
||||
}
|
||||
);
|
||||
|
||||
declare module 'fastify' {
|
||||
interface FastifyInstance {
|
||||
storage: Storage;
|
||||
}
|
||||
}
|
||||
|
||||
75
packages/core/server/src/routes/web/api/login.ts
Normal file
75
packages/core/server/src/routes/web/api/login.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import buildDebug from 'debug';
|
||||
import { FastifyInstance } from 'fastify';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { JWTSignOptions } from '@verdaccio/types';
|
||||
import { validatePassword } from '@verdaccio/utils';
|
||||
|
||||
const debug = buildDebug('verdaccio:api:login');
|
||||
|
||||
async function loginRoute(fastify: FastifyInstance) {
|
||||
fastify.post('/login', async (request, reply) => {
|
||||
// @ts-expect-error
|
||||
const { username, password } = request.body;
|
||||
debug('authenticate %o', username);
|
||||
fastify.auth.authenticate(
|
||||
username,
|
||||
password,
|
||||
async function callbackAuthenticate(err, user): Promise<void> {
|
||||
if (err) {
|
||||
const errorCode = err.message
|
||||
? fastify.statusCode.UNAUTHORIZED
|
||||
: fastify.statusCode.INTERNAL_ERROR;
|
||||
reply.send(fastify.errorUtils.getCode(errorCode, err.message));
|
||||
} else {
|
||||
const jWTSignOptions: JWTSignOptions = fastify.configInstance.security.web.sign;
|
||||
debug('jwtSignOptions: %o', jWTSignOptions);
|
||||
const token = await fastify.auth.jwtEncrypt(user, jWTSignOptions);
|
||||
reply.code(fastify.statusCode.OK).send({ token, username });
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
fastify.put('/reset_password', async (request, reply) => {
|
||||
if (_.isNil(request.userRemote.name)) {
|
||||
reply.send(
|
||||
fastify.errorUtils.getCode(
|
||||
fastify.statusCode.UNAUTHORIZED,
|
||||
fastify.errorUtils.API_ERROR.MUST_BE_LOGGED
|
||||
)
|
||||
);
|
||||
}
|
||||
// @ts-ignore
|
||||
const { password } = request.body;
|
||||
const { name } = request.userRemote;
|
||||
|
||||
if (validatePassword(password.new) === false) {
|
||||
fastify.auth.changePassword(
|
||||
name as string,
|
||||
password.old,
|
||||
password.new,
|
||||
(err, isUpdated): void => {
|
||||
if (_.isNil(err) && isUpdated) {
|
||||
reply.code(fastify.statusCode.OK);
|
||||
} else {
|
||||
reply.send(
|
||||
fastify.errorUtils.getInternalError(
|
||||
fastify.errorUtils.API_ERROR.INTERNAL_SERVER_ERROR
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
reply.send(
|
||||
fastify.errorUtils.getCode(
|
||||
fastify.statusCode.BAD_REQUEST,
|
||||
fastify.errorUtils.APP_ERROR.PASSWORD_VALIDATION
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
// });
|
||||
}
|
||||
export default loginRoute;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user