Compare commits

..

102 Commits

Author SHA1 Message Date
github-actions[bot]
fa3d878286 chore: update versions (6-next) (#2625)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2021-11-05 17:29:26 +01:00
Diana Morales
20c9e43edc dist-tags endpoint fastify (#2638)
* Create dist-tags.ts

* feat:migrate dist-tags to fastify

* Update storage.ts

Uncomment self.filters code

* add changeset
2021-11-05 16:59:13 +01:00
Diana Morales
18dc5f1f2f feat: migrate web login endpoint to fastify (#2624)
* feat: migrate login to fastify

* Update package.json

* Update server.ts

* fix authentication tests

* fix test
2021-11-05 16:29:48 +01:00
renovate[bot]
b7d319c5be chore(deps): update dependency @types/react to v17.0.34 (#2628)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-11-04 09:38:57 +01:00
Diana Morales
f86c31ed0e feat: migrate sidebar to fastify (#2618) 2021-11-03 20:56:36 +01:00
renovate[bot]
076f0f85e8 fix(deps): update docusaurus monorepo to v2.0.0-beta.9 (#2622)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-11-03 18:25:53 +01:00
Diana Morales
c2a1f4a73a use warning code for deprecation warnings (#2615) 2021-10-31 15:49:06 +01:00
Diana Morales
41475949ba feat: migrate readme to fastify (#2613)
* feat: migrate readme to fastify

* Update readme.ts
2021-10-31 15:00:04 +01:00
renovate[bot]
d390a66158 chore(deps): update dependency @types/validator to v13.6.6 (#2609) 2021-10-30 14:15:58 +02:00
renovate[bot]
7041a4381e chore(deps): update dependency css-loader to v6.5.0 (#2608) 2021-10-30 11:32:31 +02:00
renovate[bot]
14d973c552 chore(deps): update dependency redux to v4.1.2 (#2602) 2021-10-29 18:55:30 +02:00
Behrang Yarahmadi
13310814da #2606 add prettier plugin sort imports (#2607)
* #2606 add prettier plugin sort imprts

* #2606 update pnpm-lock.yaml

* #2606 update eslint rules

* #2606 fixes website directory formatting

Co-authored-by: Ayush Sharma <ayush.sharma@trivago.com>
2021-10-29 17:33:05 +02:00
Juan Picado
16458f801e refactor: pass options instead request object (#2605) 2021-10-29 09:00:02 +02:00
renovate[bot]
1322ffc2c4 chore(deps): update dependency @types/node to v16.11.6 (#2603) 2021-10-29 05:24:10 +02:00
renovate[bot]
2091f268d3 chore(deps): update dependency tmp-promise to v3.0.3 (#2592) 2021-10-28 21:40:22 +02:00
renovate[bot]
28331ff07a chore(deps): update dependency @crowdin/cli to v3.7.1 (#2601)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-28 17:44:57 +02:00
renovate[bot]
1ad1214c5e chore(deps): update dependency @testing-library/dom to v8.10.1 (#2583)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-28 17:12:24 +02:00
Juan Picado
cf4489abb1 feat: download tarball endpoint fastify (#2600) 2021-10-27 23:06:41 +02:00
Diana Morales
d7bf5453b1 feat:migrate whoami to fastify (#2599) 2021-10-27 21:34:30 +02:00
github-actions[bot]
3184ed41d8 chore: update versions (6-next) (#2597)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2021-10-27 18:16:16 +02:00
David Goldfarb
0525ebfda3 Explain the need to supply config file in Docker mount (#2598)
Co-authored-by: Juan Picado <juanpicado19@gmail.com>
2021-10-27 18:07:28 +02:00
Diana Morales
6c1eb021ba feat: use warning codes for deprecation warnings (#2595)
* feat: use warning codes for deprecation warnings

* Update logger.spec.ts

* Update package.json
2021-10-27 16:53:02 +02:00
renovate[bot]
1016fc0ff1 chore(deps): update dependency @types/react to v17.0.33 (#2589) 2021-10-27 10:01:43 +02:00
Juan Picado
30875acc70 feat: partially implement user endpoints with fastify (part1) (#2301)
Partially implemented (wip)

- requires follow up for proper token validation
-  no test included (still experimental)
-  types refactoring required, still need alignment with other modules
2021-10-26 22:03:06 +02:00
renovate[bot]
3dc5b5045f chore(deps): update dependency react-redux to v7.2.6 (#2591) 2021-10-26 20:58:44 +02:00
renovate[bot]
0f21053e04 chore(deps): update dependency @types/react-router-dom to v5.3.2 (#2590) 2021-10-26 19:28:40 +02:00
renovate[bot]
a264faba47 chore(deps): update dependency verdaccio to v5.2.0 (#2584)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-26 17:12:07 +02:00
renovate[bot]
d7005e6029 chore(deps): update dependency webpack to v5.60.0 (#2585)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-26 08:09:14 +02:00
renovate[bot]
36b5ecd2dc chore(deps): update jest monorepo to v27.3.1 (#2586)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-25 21:29:10 +02:00
renovate[bot]
9c03e11cfa chore(deps): update dependency @types/react to v17.0.32 (#2580) 2021-10-24 18:14:59 +02:00
renovate[bot]
640b92667f fix(deps): update dependency marked to v3.0.8 (#2576)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-24 15:24:13 +02:00
renovate[bot]
8478bd97b8 fix(deps): update docusaurus monorepo to v2.0.0-beta.8 (#2577)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-24 15:01:43 +02:00
Juan Picado
3836595506 chore: website version bump
need to automate this eventually
2021-10-24 10:22:21 +02:00
renovate[bot]
7bac933b81 chore(deps): update dependency typescript to v4.4.4 (#2575) 2021-10-24 09:22:23 +02:00
renovate[bot]
5cb4e6dc2f chore(deps): update dependency @types/validator to v13.6.5 (#2573) 2021-10-24 08:42:19 +02:00
renovate[bot]
57d26af661 chore(deps): update dependency nodemon to v2.0.14 (#2571) 2021-10-23 17:42:55 +02:00
renovate[bot]
497c640fc3 chore(deps): update dependency husky to v7.0.4 (#2569)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-23 08:50:42 +02:00
renovate[bot]
47415298c9 chore(deps): update dependency fastify to v3.22.1 (#2568)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-23 06:23:26 +02:00
renovate[bot]
453bfadba0 chore(deps): update dependency babel-loader to v8.2.3 (#2567)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-22 15:21:17 +02:00
renovate[bot]
a0ee7c102a chore(deps): update dependency @types/validator to v13.6.4 (#2566)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-22 13:54:55 +02:00
Juan Picado
785da5a5b3 Update renovate.json 2021-10-22 13:54:38 +02:00
renovate[bot]
ae08b22730 chore(deps): update dependency @types/react-virtualized to v9.21.14 (#2560) 2021-10-22 11:47:03 +02:00
renovate[bot]
b81417d774 chore(deps): update dependency @types/semver to v7.3.9 (#2564)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-22 08:53:40 +02:00
Juan Picado
500b25015d Merge branch 'master' of github.com:verdaccio/verdaccio 2021-10-22 07:15:02 +02:00
Juan Picado
71fb7d1223 chore: update renovate config 2021-10-22 07:14:54 +02:00
renovate[bot]
162d64e053 chore(deps): update dependency @types/react-dom to v17.0.10 (#2555)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-22 07:03:16 +02:00
Juan Picado
5776015058 chore: improve version detection (#2558) 2021-10-21 23:29:58 +02:00
renovate[bot]
f345fefd99 chore(deps): update dependency @types/react to v17.0.31 (#2554)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-21 22:47:48 +02:00
renovate[bot]
f6ffddbb5b chore(deps): update dependency @types/lodash to v4.14.176 (#2553)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Juan Picado <juanpicado19@gmail.com>
2021-10-21 22:16:07 +02:00
renovate[bot]
98fbff4e1d chore(deps): update dependency terser-webpack-plugin to v5.2.4 (#2504) 2021-10-21 21:38:18 +02:00
renovate[bot]
d1aa663553 chore(deps): update dependency esbuild-loader to v2.16.0 (#2536)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-21 08:40:44 +02:00
renovate[bot]
7fc26bf026 chore(deps): update dependency @types/pino to v6.3.12 (#2547)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-21 08:26:45 +02:00
renovate[bot]
255e41ffce chore(deps): update dependency jest-junit to v12.3.0 (#2542)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-20 07:44:00 +02:00
millerick
9ae112e129 fix: typos in documentation and website (#2540) 2021-10-19 08:57:56 +02:00
renovate[bot]
ed32c53af8 chore(deps): update dependency html-webpack-plugin to v5.4.0 (#2541)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-19 08:28:05 +02:00
renovate[bot]
49dfeed37d chore(deps): update dependency fastify to v3.22.0 (#2537)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-19 08:02:03 +02:00
Juan Picado
b56d5cec39 chore: refactor pkgs location (#2538)
* chore: relocated mock package

* refactor: relocate local-storage htpasswd to plugins

because they are

* chore: format
2021-10-18 22:18:09 +02:00
Juan Picado
70d66eb473 chore: reduce warnings eslint (#2515) 2021-10-18 21:36:53 +02:00
renovate[bot]
ffb087887a chore(deps): update dependency css-loader to v6.4.0 (#2533)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-18 21:36:14 +02:00
renovate[bot]
120dbd98ad chore(deps): update dependency @types/react-router-dom to v5.3.1 (#2531)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-18 17:50:29 +02:00
renovate[bot]
f31e1b4643 fix(deps): update docusaurus monorepo to v2.0.0-beta.7 (#2518)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-18 06:54:27 +02:00
renovate[bot]
5f8e886d3f chore(deps): update dependency @testing-library/dom to v8.9.1 (#2529)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-17 23:21:24 +02:00
renovate[bot]
7a37508b96 chore(deps): update dependency @emotion/jest to v11.5.0 (#2527)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-17 18:39:34 +02:00
renovate[bot]
c4a3be5557 fix(deps): update dependency pino to v6.13.3 (#2523)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-17 17:23:24 +02:00
renovate[bot]
90bd8eb75a chore(deps): update dependency concurrently to v6.3.0 (#2522)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-17 16:36:30 +02:00
renovate[bot]
c179a8afee chore(deps): update dependency autocannon to v7.5.0 (#2521)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-17 15:46:34 +02:00
renovate[bot]
9f0468de48 fix(deps): update dependency yarn to v1.22.17 (#2516)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-17 15:46:14 +02:00
renovate[bot]
ef93beb986 fix(deps): update dependency semver to v7.3.5 (#2524)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-17 13:02:45 +02:00
renovate[bot]
2dedb56b38 fix(deps): update dependency yup to v0.32.11 (#2517)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-17 11:51:08 +02:00
renovate[bot]
9b978c6a5f fix(deps): update dependency globby to v11.0.4 (#2508)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-17 08:42:04 +02:00
renovate[bot]
d102fe5ba0 chore(deps): update dependency node-html-parser to v4.1.5 (#2495)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-17 07:37:53 +02:00
renovate[bot]
353a283b40 fix(deps): update dependency marked to v3.0.7 (#2509) 2021-10-16 23:26:13 +02:00
renovate[bot]
e85ed294d7 fix(deps): update dependency node-fetch to v2.6.5 (#2510) 2021-10-16 22:59:42 +02:00
renovate[bot]
58f35350fa fix(deps): update dependency dompurify to v2.3.3 (#2507) 2021-10-16 22:02:44 +02:00
renovate[bot]
a3e7dd69d6 chore(deps): update dependency xss to v1.0.10 (#2506) 2021-10-16 22:02:15 +02:00
renovate[bot]
4813595e40 fix(deps): update dependency npm to v7.24.2 (#2502)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Juan Picado <juanpicado19@gmail.com>
2021-10-16 21:22:58 +02:00
renovate[bot]
ea86dde011 chore(deps): update dependency update-ts-references to v2.4.1 (#2505)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Juan Picado <juanpicado19@gmail.com>
2021-10-16 20:24:57 +02:00
renovate[bot]
d0d4d0fd8f chore(deps): update dependency react-redux to v7.2.5 (#2503)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Juan Picado <juanpicado19@gmail.com>
2021-10-16 20:24:31 +02:00
renovate[bot]
cfdd2ae698 chore(deps): update typescript-eslint monorepo to v4.33.0 (#2499)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Juan Picado <juanpicado19@gmail.com>
2021-10-16 19:46:32 +02:00
renovate[bot]
f2ab24943d chore(deps): update dependency nodemon to v2.0.13 (#2496)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-16 19:24:15 +02:00
renovate[bot]
e6bc577379 chore(deps): update dependency @crowdin/cli to v3.7.0 (#2497) 2021-10-16 18:46:54 +02:00
renovate[bot]
c4fc24f38e chore(deps): update jest monorepo to v27.2.5 (#2498) 2021-10-16 18:46:05 +02:00
renovate[bot]
066cc819a8 fix(deps): update dependency clipanion to v3.1.0 (#2501) 2021-10-16 18:29:01 +02:00
renovate[bot]
81ea129d80 chore(deps): update dependency fast-crc32c to v1.0.7 (#2494) 2021-10-16 17:01:53 +02:00
renovate[bot]
af174f0c8c chore(deps): update dependency dayjs to v1.10.7 (#2493) 2021-10-16 17:01:23 +02:00
renovate[bot]
c11a5958a6 chore(deps): update dependency @types/webpack-env to v1.16.3 (#2491) 2021-10-16 16:13:37 +02:00
renovate[bot]
0e1c078ecd chore(deps): update dependency @types/jest to v27.0.2 (#2487) 2021-10-16 16:13:19 +02:00
renovate[bot]
836a8702cc chore(deps): update dependency @types/react to v17.0.30 (#2489) 2021-10-16 15:33:43 +02:00
renovate[bot]
0d8ecab1ba chore(deps): update dependency @types/lodash to v4.14.175 (#2488) 2021-10-16 15:33:12 +02:00
renovate[bot]
ccf92cabdc chore(deps): update dependency country-flag-icons to v1.4.11 (#2492) 2021-10-16 15:32:17 +02:00
renovate[bot]
7f0b4db9f8 chore(deps): update dependency @types/react-helmet to v6.1.4 (#2490) 2021-10-16 15:09:57 +02:00
renovate[bot]
76e62134a3 chore(deps): update dependency @types/express to v4.17.13 (#2486) 2021-10-16 14:47:10 +02:00
renovate[bot]
31f5a94098 chore(deps): update dependency @rematch/core to v2.1.1 (#2480) 2021-10-16 14:29:17 +02:00
renovate[bot]
a22300afcf chore(deps): update dependency @rematch/loading to v2.1.1 (#2481) 2021-10-16 13:53:51 +02:00
renovate[bot]
717e42b383 chore(deps): update dependency @testing-library/react to v12.1.2 (#2485) 2021-10-16 12:56:03 +02:00
renovate[bot]
91e043addc chore(deps): update dependency verdaccio to v5.1.6 (#2484) 2021-10-16 12:20:26 +02:00
renovate[bot]
dd9726957f fix(deps): update dependency debug to v4.3.2 (#2482) 2021-10-16 12:05:19 +02:00
renovate[bot]
9230779af1 fix(deps): update dependency lodash to v4.17.21 (#2483) 2021-10-16 11:41:34 +02:00
renovate[bot]
6bef6d879a chore(deps): update babel monorepo (#2478)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-16 10:24:29 +02:00
renovate[bot]
ef6c7d9f0e chore(deps): update actions/checkout action to v2.3.5 (#2477)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-16 10:19:59 +02:00
renovate[bot]
4cc5411056 Configure Renovate (#2452)
* Add renovate.json

* update renovate

* renovate update conf

* ignore docker examples

* ignore @verdaccio/helper

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Juan Picado <juanpicado19@gmail.com>
2021-10-16 10:04:21 +02:00
Juan Picado
9d96fa7e53 Update CONTRIBUTING.md 2021-10-16 09:39:05 +02:00
571 changed files with 7039 additions and 4815 deletions

View File

@@ -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",

View 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

View 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

View File

@@ -0,0 +1,7 @@
---
'@verdaccio/auth': minor
'@verdaccio/fastify-migration': minor
'@verdaccio/web': minor
---
dist tags Implementation on Fastify

View File

@@ -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

View File

@@ -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.

View File

@@ -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

View File

@@ -1,11 +0,0 @@
{
"endOfLine": "lf",
"useTabs": false,
"printWidth": 100,
"tabWidth": 2,
"singleQuote": true,
"bracketSpacing": true,
"jsxBracketSameLine": true,
"trailingComma": "es5",
"semi": true
}

View File

@@ -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

View File

@@ -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
View 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'

View File

@@ -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",

View File

@@ -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

View File

@@ -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",

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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);

View File

@@ -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(

View File

@@ -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';

View File

@@ -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');

View File

@@ -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[];

View File

@@ -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');

View File

@@ -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

View File

@@ -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;

View File

@@ -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';

View File

@@ -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;

View File

@@ -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');

View File

@@ -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) => {

View File

@@ -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(

View File

@@ -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', () => {

View File

@@ -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(

View File

@@ -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';

View File

@@ -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';

View File

@@ -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.

View File

@@ -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;

View File

@@ -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

View File

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

View File

@@ -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)) {

View File

@@ -1,5 +1,5 @@
import jwt from 'jsonwebtoken';
import buildDebug from 'debug';
import jwt from 'jsonwebtoken';
import { JWTSignOptions, RemoteUser } from '@verdaccio/types';

View File

@@ -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';

View File

@@ -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');

View File

@@ -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([]);

View File

@@ -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();

View File

@@ -1,4 +1,5 @@
import path from 'path';
import { configExample as config } from '@verdaccio/mock';
export const authProfileConf = config({

View File

@@ -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

View File

@@ -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"

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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`]];

View File

@@ -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);

View File

@@ -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}`);
}

View File

@@ -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();
});

View File

@@ -13,6 +13,9 @@
{
"path": "../core/cli-ui"
},
{
"path": "../core/core"
},
{
"path": "../core/server"
},

View File

@@ -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

View File

@@ -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",

View File

@@ -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';

View File

@@ -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'];

View File

@@ -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;
}

View File

@@ -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';

View File

@@ -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';

View File

@@ -1,4 +1,5 @@
import os from 'os';
import { findConfigFile } from '../src/config-path';
const mockmkDir = jest.fn();

View File

@@ -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';

View File

@@ -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', () => {

View File

@@ -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();

View File

@@ -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', () => {

View File

@@ -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', () => {

View File

@@ -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

View File

@@ -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"

View File

@@ -1,4 +1,5 @@
import createError, { HttpError } from 'http-errors';
import { DEFAULT_MIN_LIMIT_PASSWORD, HTTP_STATUS } from './constants';
export const API_ERROR = {

View File

@@ -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,
};

View File

@@ -1,5 +1,7 @@
import { Package } from '@verdaccio/types';
import semver from 'semver';
import { Package } from '@verdaccio/types';
import { DIST_TAGS } from './constants';
/**

View File

@@ -1,4 +1,5 @@
import { Config, IPackageStorage, Token, TokenFilter } from '@verdaccio/types';
import { searchUtils } from '.';
interface IPlugin {

View File

@@ -1,4 +1,4 @@
import { PassThrough, TransformOptions, Transform } from 'stream';
import { PassThrough, Transform, TransformOptions } from 'stream';
export interface IReadTarball {
abort?: () => void;

View File

@@ -1,5 +1,7 @@
import assert from 'assert';
import { Package } from '@verdaccio/types';
import { DIST_TAGS } from './constants';
export function isPackageNameScoped(name: string): boolean {

View 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);
}

View File

@@ -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', () => {

View File

@@ -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', () => {

View File

@@ -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) => {

View File

@@ -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', () => {

View File

@@ -1,4 +1,5 @@
import locker from 'lockfile';
import { Callback } from '@verdaccio/types';
// unlocks file by removing existing lock file

View 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 => {

View File

@@ -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;

View File

@@ -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"

View File

@@ -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);

View File

@@ -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

View File

@@ -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');

View File

@@ -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"
},

View 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;

View File

@@ -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 {};
});
}

View File

@@ -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({

View 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;

View 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;

View 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;

View File

@@ -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;
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View File

@@ -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;
}
}

View 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