@verdaccio/api 6.0.0-6-next.23 → 6.0.0-6-next.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +124 -0
- package/build/dist-tags.js +40 -35
- package/build/dist-tags.js.map +1 -1
- package/build/index.js +1 -7
- package/build/index.js.map +1 -1
- package/build/package.js +33 -28
- package/build/package.js.map +1 -1
- package/build/ping.js.map +1 -1
- package/build/publish.d.ts +79 -22
- package/build/publish.js +89 -313
- package/build/publish.js.map +1 -1
- package/build/search.js.map +1 -1
- package/build/star.js +53 -54
- package/build/star.js.map +1 -1
- package/build/stars.js +6 -6
- package/build/stars.js.map +1 -1
- package/build/user.js +19 -1
- package/build/user.js.map +1 -1
- package/build/v1/profile.js.map +1 -1
- package/build/v1/search.js +2 -4
- package/build/v1/search.js.map +1 -1
- package/build/v1/token.js.map +1 -1
- package/build/whoami.js +11 -25
- package/build/whoami.js.map +1 -1
- package/jest.config.js +8 -1
- package/package.json +71 -69
- package/src/dist-tags.ts +63 -50
- package/src/index.ts +1 -6
- package/src/package.ts +35 -44
- package/src/publish.ts +115 -336
- package/src/star.ts +53 -52
- package/src/stars.ts +9 -11
- package/src/user.ts +19 -2
- package/src/v1/search.ts +3 -3
- package/src/whoami.ts +8 -24
- package/test/integration/_helper.ts +97 -53
- package/test/integration/config/distTag.yaml +25 -0
- package/test/integration/config/package.yaml +4 -9
- package/test/integration/config/ping.yaml +3 -7
- package/test/integration/config/publish.yaml +5 -11
- package/test/integration/config/search.yaml +29 -0
- package/test/integration/config/token.jwt.yaml +27 -0
- package/test/integration/config/token.yaml +19 -0
- package/test/integration/config/user.jwt.yaml +37 -0
- package/test/integration/config/user.yaml +9 -15
- package/test/integration/config/whoami.yaml +5 -12
- package/test/integration/distTag.spec.ts +76 -0
- package/test/integration/package.spec.ts +33 -76
- package/test/integration/ping.spec.ts +4 -3
- package/test/integration/publish.spec.ts +61 -26
- package/test/integration/search.spec.ts +126 -0
- package/test/integration/token.spec.ts +124 -0
- package/test/integration/user.jwt.spec.ts +87 -0
- package/test/integration/user.spec.ts +1 -0
- package/test/integration/whoami.spec.ts +21 -39
- package/test/unit/publish.disabled.ts +252 -0
- package/tsconfig.json +1 -1
- package/__mocks__/@verdaccio/logger/index.js +0 -21
- package/build/utils.d.ts +0 -7
- package/build/utils.js +0 -36
- package/build/utils.js.map +0 -1
- package/src/utils.ts +0 -25
- package/test/unit/__snapshots__/publish.spec.ts.snap +0 -49
- package/test/unit/publish.spec.ts +0 -300
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,129 @@
|
|
|
1
1
|
# @verdaccio/api
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.26
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 292c0a37: feat!: replace deprecated request dependency by got
|
|
8
|
+
|
|
9
|
+
This is a big refactoring of the core, fetching dependencies, improve code, more tests and better stability. This is essential for the next release, will take some time but would allow modularize more the core.
|
|
10
|
+
|
|
11
|
+
## Notes
|
|
12
|
+
|
|
13
|
+
- Remove deprecated `request` by other `got`, retry improved, custom Agent ( got does not include it built-in)
|
|
14
|
+
- Remove `async` dependency from storage (used by core) it was linked with proxy somehow safe to remove now
|
|
15
|
+
- Refactor with promises instead callback wherever is possible
|
|
16
|
+
- ~Document the API~
|
|
17
|
+
- Improve testing, integration tests
|
|
18
|
+
- Bugfix
|
|
19
|
+
- Clean up old validations
|
|
20
|
+
- Improve performance
|
|
21
|
+
|
|
22
|
+
## 💥 Breaking changes
|
|
23
|
+
|
|
24
|
+
- Plugin API methods were callbacks based are returning promises, this will break current storage plugins, check documentation for upgrade.
|
|
25
|
+
- Write Tarball, Read Tarball methods parameters change, a new set of options like `AbortController` signals are being provided to the `addAbortSignal` can be internally used with Streams when a request is aborted. eg: `addAbortSignal(signal, fs.createReadStream(pathName));`
|
|
26
|
+
- `@verdaccio/streams` stream abort support is legacy is being deprecated removed
|
|
27
|
+
- Remove AWS and Google Cloud packages for future refactoring [#2574](https://github.com/verdaccio/verdaccio/pull/2574).
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- 00d1d2a1: chore: env variable for launch fastify
|
|
32
|
+
|
|
33
|
+
- Update fastify to major release `v4.3.0`
|
|
34
|
+
- Update CLI launcher
|
|
35
|
+
|
|
36
|
+
via CLI
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
VERDACCIO_SERVER=fastify verdaccio
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
with docker
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
docker run -it --rm --name verdaccio \
|
|
46
|
+
-e "VERDACCIO_SERVER=8080" -p 8080:8080 \
|
|
47
|
+
-e "VERDACCIO_SERVER=fastify" \
|
|
48
|
+
verdaccio/verdaccio
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [292c0a37]
|
|
54
|
+
- Updated dependencies [a3a209b5]
|
|
55
|
+
- Updated dependencies [00d1d2a1]
|
|
56
|
+
- @verdaccio/auth@6.0.0-6-next.23
|
|
57
|
+
- @verdaccio/config@6.0.0-6-next.15
|
|
58
|
+
- @verdaccio/core@6.0.0-6-next.6
|
|
59
|
+
- @verdaccio/logger@6.0.0-6-next.12
|
|
60
|
+
- @verdaccio/middleware@6.0.0-6-next.23
|
|
61
|
+
- @verdaccio/store@6.0.0-6-next.23
|
|
62
|
+
- @verdaccio/utils@6.0.0-6-next.12
|
|
63
|
+
|
|
64
|
+
## 6.0.0-6-next.25
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- Updated dependencies [d43894e8]
|
|
69
|
+
- Updated dependencies [d08fe29d]
|
|
70
|
+
- @verdaccio/config@6.0.0-6-next.14
|
|
71
|
+
- @verdaccio/auth@6.0.0-6-next.22
|
|
72
|
+
- @verdaccio/hooks@6.0.0-6-next.13
|
|
73
|
+
- @verdaccio/store@6.0.0-6-next.22
|
|
74
|
+
- @verdaccio/core@6.0.0-6-next.5
|
|
75
|
+
- @verdaccio/logger@6.0.0-6-next.11
|
|
76
|
+
- @verdaccio/middleware@6.0.0-6-next.22
|
|
77
|
+
|
|
78
|
+
## 6.0.0-6-next.24
|
|
79
|
+
|
|
80
|
+
### Major Changes
|
|
81
|
+
|
|
82
|
+
- 82cb0f2b: feat!: config.logs throw an error, logging config not longer accept array or logs property
|
|
83
|
+
|
|
84
|
+
### 💥 Breaking change
|
|
85
|
+
|
|
86
|
+
This is valid
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
log: { type: stdout, format: pretty, level: http }
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
This is invalid
|
|
93
|
+
|
|
94
|
+
```yaml
|
|
95
|
+
logs: { type: stdout, format: pretty, level: http }
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
or
|
|
99
|
+
|
|
100
|
+
```yaml
|
|
101
|
+
logs:
|
|
102
|
+
- [{ type: stdout, format: pretty, level: http }]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Minor Changes
|
|
106
|
+
|
|
107
|
+
- 5167bb52: feat: ui search support for remote, local and private packages
|
|
108
|
+
|
|
109
|
+
The command `npm search` search globally and return all matches, with this improvement the user interface
|
|
110
|
+
is powered with the same capabilities.
|
|
111
|
+
|
|
112
|
+
The UI also tag where is the origin the package with a tag, also provide the latest version and description of the package.
|
|
113
|
+
|
|
114
|
+
### Patch Changes
|
|
115
|
+
|
|
116
|
+
- Updated dependencies [82cb0f2b]
|
|
117
|
+
- Updated dependencies [5167bb52]
|
|
118
|
+
- @verdaccio/config@6.0.0-6-next.13
|
|
119
|
+
- @verdaccio/core@6.0.0-6-next.5
|
|
120
|
+
- @verdaccio/logger@6.0.0-6-next.11
|
|
121
|
+
- @verdaccio/store@6.0.0-6-next.21
|
|
122
|
+
- @verdaccio/auth@6.0.0-6-next.21
|
|
123
|
+
- @verdaccio/hooks@6.0.0-6-next.13
|
|
124
|
+
- @verdaccio/middleware@6.0.0-6-next.21
|
|
125
|
+
- @verdaccio/utils@6.0.0-6-next.11
|
|
126
|
+
|
|
3
127
|
## 6.0.0-6-next.23
|
|
4
128
|
|
|
5
129
|
### Patch Changes
|
package/build/dist-tags.js
CHANGED
|
@@ -18,68 +18,73 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
18
|
function _default(route, auth, storage) {
|
|
19
19
|
const can = (0, _middleware.allow)(auth);
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const addTagPackageVersionMiddleware = async function (req, res, next) {
|
|
22
22
|
if (_lodash.default.isString(req.body) === false) {
|
|
23
|
-
return next('
|
|
23
|
+
return next(_core.errorUtils.getBadRequest('version is missing'));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const tags = {};
|
|
27
27
|
tags[req.params.tag] = req.body;
|
|
28
|
-
storage.mergeTags(req.params.package, tags, function (err) {
|
|
29
|
-
if (err) {
|
|
30
|
-
return next(err);
|
|
31
|
-
}
|
|
32
28
|
|
|
29
|
+
try {
|
|
30
|
+
await storage.mergeTagsNext(req.params.package, tags);
|
|
33
31
|
res.status(_core.constants.HTTP_STATUS.CREATED);
|
|
34
32
|
return next({
|
|
35
33
|
ok: _core.constants.API_MESSAGE.TAG_ADDED
|
|
36
34
|
});
|
|
37
|
-
})
|
|
35
|
+
} catch (err) {
|
|
36
|
+
next(err);
|
|
37
|
+
}
|
|
38
38
|
}; // tagging a package.
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
route.put('/:package/:tag', can('publish'), (0, _middleware.media)(_mime.default.getType('json')),
|
|
42
|
-
route.
|
|
43
|
-
route.
|
|
44
|
-
route.delete('/-/package/:package/dist-tags/:tag', can('publish'), function (req, res, next) {
|
|
41
|
+
route.put('/:package/:tag', can('publish'), (0, _middleware.media)(_mime.default.getType('json')), addTagPackageVersionMiddleware);
|
|
42
|
+
route.put('/-/package/:package/dist-tags/:tag', can('publish'), (0, _middleware.media)(_mime.default.getType('json')), addTagPackageVersionMiddleware);
|
|
43
|
+
route.delete('/-/package/:package/dist-tags/:tag', can('publish'), async function (req, res, next) {
|
|
45
44
|
const tags = {};
|
|
46
45
|
tags[req.params.tag] = null;
|
|
47
|
-
storage.mergeTags(req.params.package, tags, function (err) {
|
|
48
|
-
if (err) {
|
|
49
|
-
return next(err);
|
|
50
|
-
}
|
|
51
46
|
|
|
47
|
+
try {
|
|
48
|
+
await storage.mergeTagsNext(req.params.package, tags);
|
|
52
49
|
res.status(_core.constants.HTTP_STATUS.CREATED);
|
|
53
50
|
return next({
|
|
54
51
|
ok: _core.constants.API_MESSAGE.TAG_REMOVED
|
|
55
52
|
});
|
|
56
|
-
})
|
|
53
|
+
} catch (err) {
|
|
54
|
+
next(err);
|
|
55
|
+
}
|
|
57
56
|
});
|
|
58
|
-
route.get('/-/package/:package/dist-tags', can('access'), function (req, res, next) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
req,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
route.get('/-/package/:package/dist-tags', can('access'), async function (req, res, next) {
|
|
58
|
+
const name = req.params.package;
|
|
59
|
+
const requestOptions = {
|
|
60
|
+
protocol: req.protocol,
|
|
61
|
+
headers: req.headers,
|
|
62
|
+
// FIXME: if we migrate to req.hostname, the port is not longer included.
|
|
63
|
+
host: req.host,
|
|
64
|
+
remoteAddress: req.socket.remoteAddress
|
|
65
|
+
};
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
try {
|
|
68
|
+
const manifest = await storage.getPackageByOptions({
|
|
69
|
+
name,
|
|
70
|
+
uplinksLook: true,
|
|
71
|
+
requestOptions
|
|
72
|
+
});
|
|
73
|
+
next(manifest[_core.constants.DIST_TAGS]);
|
|
74
|
+
} catch (err) {
|
|
75
|
+
next(err);
|
|
76
|
+
}
|
|
71
77
|
});
|
|
72
|
-
route.post('/-/package/:package/dist-tags', can('publish'), function (req, res, next) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return next(err);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
+
route.post('/-/package/:package/dist-tags', can('publish'), async function (req, res, next) {
|
|
79
|
+
try {
|
|
80
|
+
await storage.mergeTagsNext(req.params.package, req.body);
|
|
78
81
|
res.status(_core.constants.HTTP_STATUS.CREATED);
|
|
79
82
|
return next({
|
|
80
83
|
ok: _core.constants.API_MESSAGE.TAG_UPDATED
|
|
81
84
|
});
|
|
82
|
-
})
|
|
85
|
+
} catch (err) {
|
|
86
|
+
next(err);
|
|
87
|
+
}
|
|
83
88
|
});
|
|
84
89
|
}
|
|
85
90
|
//# sourceMappingURL=dist-tags.js.map
|
package/build/dist-tags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"dist-tags.js","names":["route","auth","storage","can","allow","addTagPackageVersionMiddleware","req","res","next","_","isString","body","errorUtils","getBadRequest","tags","params","tag","mergeTagsNext","package","status","constants","HTTP_STATUS","CREATED","ok","API_MESSAGE","TAG_ADDED","err","put","media","mime","getType","delete","TAG_REMOVED","get","name","requestOptions","protocol","headers","host","remoteAddress","socket","manifest","getPackageByOptions","uplinksLook","DIST_TAGS","post","TAG_UPDATED"],"sources":["../src/dist-tags.ts"],"sourcesContent":["import { Router } from 'express';\nimport _ from 'lodash';\nimport mime from 'mime';\n\nimport { IAuth } from '@verdaccio/auth';\nimport { constants, errorUtils } from '@verdaccio/core';\nimport { allow, media } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';\n\nexport default function (route: Router, auth: IAuth, storage: Storage): void {\n const can = allow(auth);\n const addTagPackageVersionMiddleware = async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<$NextFunctionVer> {\n if (_.isString(req.body) === false) {\n return next(errorUtils.getBadRequest('version is missing'));\n }\n\n const tags = {};\n tags[req.params.tag] = req.body;\n try {\n await storage.mergeTagsNext(req.params.package, tags);\n res.status(constants.HTTP_STATUS.CREATED);\n return next({\n ok: constants.API_MESSAGE.TAG_ADDED,\n });\n } catch (err) {\n next(err);\n }\n };\n\n // tagging a package.\n route.put(\n '/:package/:tag',\n can('publish'),\n media(mime.getType('json')),\n addTagPackageVersionMiddleware\n );\n\n route.put(\n '/-/package/:package/dist-tags/:tag',\n can('publish'),\n media(mime.getType('json')),\n addTagPackageVersionMiddleware\n );\n\n route.delete(\n '/-/package/:package/dist-tags/:tag',\n can('publish'),\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n const tags = {};\n tags[req.params.tag] = null;\n try {\n await storage.mergeTagsNext(req.params.package, tags);\n res.status(constants.HTTP_STATUS.CREATED);\n return next({\n ok: constants.API_MESSAGE.TAG_REMOVED,\n });\n } catch (err) {\n next(err);\n }\n }\n );\n\n route.get(\n '/-/package/:package/dist-tags',\n can('access'),\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n const name = req.params.package;\n const requestOptions = {\n protocol: req.protocol,\n headers: req.headers as any,\n // FIXME: if we migrate to req.hostname, the port is not longer included.\n host: req.host,\n remoteAddress: req.socket.remoteAddress,\n };\n try {\n const manifest = await storage.getPackageByOptions({\n name,\n uplinksLook: true,\n requestOptions,\n });\n next(manifest[constants.DIST_TAGS]);\n } catch (err) {\n next(err);\n }\n }\n );\n\n route.post(\n '/-/package/:package/dist-tags',\n can('publish'),\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n try {\n await storage.mergeTagsNext(req.params.package, req.body);\n res.status(constants.HTTP_STATUS.CREATED);\n return next({\n ok: constants.API_MESSAGE.TAG_UPDATED,\n });\n } catch (err) {\n next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AI,CAACkB,GAAD,CAAJ;IACD;EACF,CA1BH;EA6BA1B,KAAK,CAAC6C,IAAN,CACE,+BADF,EAEE1C,GAAG,CAAC,SAAD,CAFL,EAGE,gBACEG,GADF,EAEEC,GAFF,EAGEC,IAHF,EAIiB;IACf,IAAI;MACF,MAAMN,OAAO,CAACe,aAAR,CAAsBX,GAAG,CAACS,MAAJ,CAAWG,OAAjC,EAA0CZ,GAAG,CAACK,IAA9C,CAAN;MACAJ,GAAG,CAACY,MAAJ,CAAWC,eAAA,CAAUC,WAAV,CAAsBC,OAAjC;MACA,OAAOd,IAAI,CAAC;QACVe,EAAE,EAAEH,eAAA,CAAUI,WAAV,CAAsBsB;MADhB,CAAD,CAAX;IAGD,CAND,CAME,OAAOpB,GAAP,EAAY;MACZlB,IAAI,CAACkB,GAAD,CAAJ;IACD;EACF,CAjBH;AAmBD"}
|
package/build/index.js
CHANGED
|
@@ -9,8 +9,6 @@ var _bodyParser = _interopRequireDefault(require("body-parser"));
|
|
|
9
9
|
|
|
10
10
|
var _express = _interopRequireDefault(require("express"));
|
|
11
11
|
|
|
12
|
-
var _semver = _interopRequireDefault(require("semver"));
|
|
13
|
-
|
|
14
12
|
var _middleware = require("@verdaccio/middleware");
|
|
15
13
|
|
|
16
14
|
var _distTags = _interopRequireDefault(require("./dist-tags"));
|
|
@@ -37,10 +35,6 @@ var _whoami = _interopRequireDefault(require("./whoami"));
|
|
|
37
35
|
|
|
38
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
37
|
|
|
40
|
-
if (_semver.default.lte(process.version, 'v15.0.0')) {
|
|
41
|
-
global.AbortController = require('abortcontroller-polyfill/dist/cjs-ponyfill').AbortController;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
38
|
function _default(config, auth, storage) {
|
|
45
39
|
/* eslint new-cap:off */
|
|
46
40
|
const app = _express.default.Router();
|
|
@@ -77,7 +71,7 @@ function _default(config, auth, storage) {
|
|
|
77
71
|
(0, _search.default)(app);
|
|
78
72
|
(0, _user.default)(app, auth, config);
|
|
79
73
|
(0, _distTags.default)(app, auth, storage);
|
|
80
|
-
(0, _publish.default)(app, auth, storage
|
|
74
|
+
(0, _publish.default)(app, auth, storage);
|
|
81
75
|
(0, _ping.default)(app);
|
|
82
76
|
(0, _stars.default)(app, storage); // @ts-ignore
|
|
83
77
|
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["config","auth","storage","app","express","Router","param","validatePackage","validateName","match","use","apiJWTmiddleware","bodyParser","json","strict","limit","max_body_size","antiLoop","encodeScopePackage","whoami","pkg","profile","search","user","distTags","publish","ping","stars","v1Search","token"],"sources":["../src/index.ts"],"sourcesContent":["import bodyParser from 'body-parser';\nimport express, { Router } from 'express';\n\nimport { IAuth } from '@verdaccio/auth';\nimport {\n antiLoop,\n encodeScopePackage,\n match,\n validateName,\n validatePackage,\n} from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { Config } from '@verdaccio/types';\n\nimport distTags from './dist-tags';\nimport pkg from './package';\nimport ping from './ping';\nimport publish from './publish';\nimport search from './search';\nimport stars from './stars';\nimport user from './user';\nimport profile from './v1/profile';\nimport v1Search from './v1/search';\nimport token from './v1/token';\nimport whoami from './whoami';\n\nexport default function (config: Config, auth: IAuth, storage: Storage): Router {\n /* eslint new-cap:off */\n const app = express.Router();\n /* eslint new-cap:off */\n\n // validate all of these params as a package name\n // this might be too harsh, so ask if it causes trouble\n app.param('package', validatePackage);\n app.param('filename', validateName);\n app.param('tag', validateName);\n app.param('version', validateName);\n app.param('revision', validateName);\n app.param('token', validateName);\n\n // these can't be safely put into express url for some reason\n // TODO: For some reason? what reason?\n app.param('_rev', match(/^-rev$/));\n app.param('org_couchdb_user', match(/^org\\.couchdb\\.user:/));\n app.param('anything', match(/.*/));\n app.use(auth.apiJWTmiddleware());\n app.use(bodyParser.json({ strict: false, limit: config.max_body_size || '10mb' }));\n // @ts-ignore\n app.use(antiLoop(config));\n // encode / in a scoped package name to be matched as a single parameter in routes\n app.use(encodeScopePackage);\n // for \"npm whoami\"\n whoami(app);\n pkg(app, auth, storage);\n profile(app, auth);\n // @deprecated endpoint, 404 by default\n search(app);\n user(app, auth, config);\n distTags(app, auth, storage);\n publish(app, auth, storage);\n ping(app);\n stars(app, storage);\n // @ts-ignore\n v1Search(app, auth, storage);\n token(app, auth, storage, config);\n return app;\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAGA;;AAUA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEe,kBAAUA,MAAV,EAA0BC,IAA1B,EAAuCC,OAAvC,EAAiE;EAC9E;EACA,MAAMC,GAAG,GAAGC,gBAAA,CAAQC,MAAR,EAAZ;EACA;EAEA;EACA;;;EACAF,GAAG,CAACG,KAAJ,CAAU,SAAV,EAAqBC,2BAArB;EACAJ,GAAG,CAACG,KAAJ,CAAU,UAAV,EAAsBE,wBAAtB;EACAL,GAAG,CAACG,KAAJ,CAAU,KAAV,EAAiBE,wBAAjB;EACAL,GAAG,CAACG,KAAJ,CAAU,SAAV,EAAqBE,wBAArB;EACAL,GAAG,CAACG,KAAJ,CAAU,UAAV,EAAsBE,wBAAtB;EACAL,GAAG,CAACG,KAAJ,CAAU,OAAV,EAAmBE,wBAAnB,EAZ8E,CAc9E;EACA;;EACAL,GAAG,CAACG,KAAJ,CAAU,MAAV,EAAkB,IAAAG,iBAAA,EAAM,QAAN,CAAlB;EACAN,GAAG,CAACG,KAAJ,CAAU,kBAAV,EAA8B,IAAAG,iBAAA,EAAM,sBAAN,CAA9B;EACAN,GAAG,CAACG,KAAJ,CAAU,UAAV,EAAsB,IAAAG,iBAAA,EAAM,IAAN,CAAtB;EACAN,GAAG,CAACO,GAAJ,CAAQT,IAAI,CAACU,gBAAL,EAAR;EACAR,GAAG,CAACO,GAAJ,CAAQE,mBAAA,CAAWC,IAAX,CAAgB;IAAEC,MAAM,EAAE,KAAV;IAAiBC,KAAK,EAAEf,MAAM,CAACgB,aAAP,IAAwB;EAAhD,CAAhB,CAAR,EApB8E,CAqB9E;;EACAb,GAAG,CAACO,GAAJ,CAAQ,IAAAO,oBAAA,EAASjB,MAAT,CAAR,EAtB8E,CAuB9E;;EACAG,GAAG,CAACO,GAAJ,CAAQQ,8BAAR,EAxB8E,CAyB9E;;EACA,IAAAC,eAAA,EAAOhB,GAAP;EACA,IAAAiB,gBAAA,EAAIjB,GAAJ,EAASF,IAAT,EAAeC,OAAf;EACA,IAAAmB,gBAAA,EAAQlB,GAAR,EAAaF,IAAb,EA5B8E,CA6B9E;;EACA,IAAAqB,eAAA,EAAOnB,GAAP;EACA,IAAAoB,aAAA,EAAKpB,GAAL,EAAUF,IAAV,EAAgBD,MAAhB;EACA,IAAAwB,iBAAA,EAASrB,GAAT,EAAcF,IAAd,EAAoBC,OAApB;EACA,IAAAuB,gBAAA,EAAQtB,GAAR,EAAaF,IAAb,EAAmBC,OAAnB;EACA,IAAAwB,aAAA,EAAKvB,GAAL;EACA,IAAAwB,cAAA,EAAMxB,GAAN,EAAWD,OAAX,EAnC8E,CAoC9E;;EACA,IAAA0B,gBAAA,EAASzB,GAAT,EAAcF,IAAd,EAAoBC,OAApB;EACA,IAAA2B,cAAA,EAAM1B,GAAN,EAAWF,IAAX,EAAiBC,OAAjB,EAA0BF,MAA1B;EACA,OAAOG,GAAP;AACD"}
|
package/build/package.js
CHANGED
|
@@ -15,43 +15,27 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
15
15
|
|
|
16
16
|
const debug = (0, _debug.default)('verdaccio:api:package');
|
|
17
17
|
|
|
18
|
-
const downloadStream = (packageName, filename, storage, _req, res) => {
|
|
19
|
-
const stream = storage.getTarball(packageName, filename);
|
|
20
|
-
stream.on('content-length', function (content) {
|
|
21
|
-
res.header('Content-Length', content);
|
|
22
|
-
});
|
|
23
|
-
stream.on('error', function (err) {
|
|
24
|
-
return res.locals.report_error(err);
|
|
25
|
-
});
|
|
26
|
-
res.header(_core.HEADERS.CONTENT_TYPE, _core.HEADERS.OCTET_STREAM);
|
|
27
|
-
stream.pipe(res);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
18
|
function _default(route, auth, storage) {
|
|
31
19
|
const can = (0, _middleware.allow)(auth);
|
|
32
20
|
route.get('/:package/:version?', can('access'), async function (req, _res, next) {
|
|
33
21
|
debug('init package by version');
|
|
34
22
|
const name = req.params.package;
|
|
35
|
-
let
|
|
23
|
+
let version = req.params.version;
|
|
24
|
+
const write = req.query.write === 'true';
|
|
36
25
|
const requestOptions = {
|
|
37
26
|
protocol: req.protocol,
|
|
38
27
|
headers: req.headers,
|
|
39
28
|
// FIXME: if we migrate to req.hostname, the port is not longer included.
|
|
40
|
-
host: req.host
|
|
29
|
+
host: req.host,
|
|
30
|
+
remoteAddress: req.socket.remoteAddress,
|
|
31
|
+
byPassCache: write
|
|
41
32
|
};
|
|
42
33
|
|
|
43
34
|
try {
|
|
44
|
-
// TODO: this is just temporary while I migrate all plugins to use the new API
|
|
45
|
-
// the method will be renamed to getPackage again but Promise Based.
|
|
46
|
-
if (!storage.getPackageByOptions) {
|
|
47
|
-
throw _core.errorUtils.getInternalError('getPackageByOptions not implemented, check pr-2750 for more details');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
35
|
const manifest = await storage.getPackageByOptions({
|
|
51
36
|
name,
|
|
52
37
|
uplinksLook: true,
|
|
53
|
-
|
|
54
|
-
version: queryVersion,
|
|
38
|
+
version,
|
|
55
39
|
requestOptions
|
|
56
40
|
});
|
|
57
41
|
next(manifest);
|
|
@@ -59,15 +43,36 @@ function _default(route, auth, storage) {
|
|
|
59
43
|
next(err);
|
|
60
44
|
}
|
|
61
45
|
});
|
|
62
|
-
route.get('/:
|
|
46
|
+
route.get('/:pkg/-/:filename', can('access'), async function (req, res, next) {
|
|
63
47
|
const {
|
|
64
|
-
|
|
48
|
+
pkg,
|
|
65
49
|
filename
|
|
66
50
|
} = req.params;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
51
|
+
const abort = new AbortController();
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const stream = await storage.getTarballNext(pkg, filename, {
|
|
55
|
+
signal: abort.signal // enableRemote: true,
|
|
56
|
+
|
|
57
|
+
});
|
|
58
|
+
stream.on('content-length', size => {
|
|
59
|
+
res.header(_core.HEADER_TYPE.CONTENT_LENGTH, size);
|
|
60
|
+
});
|
|
61
|
+
stream.once('error', err => {
|
|
62
|
+
res.locals.report_error(err);
|
|
63
|
+
next(err);
|
|
64
|
+
});
|
|
65
|
+
req.on('abort', () => {
|
|
66
|
+
debug('request aborted for %o', req.url);
|
|
67
|
+
abort.abort();
|
|
68
|
+
});
|
|
69
|
+
res.header(_core.HEADERS.CONTENT_TYPE, _core.HEADERS.OCTET_STREAM);
|
|
70
|
+
stream.pipe(res);
|
|
71
|
+
} catch (err) {
|
|
72
|
+
// console.log('catch API error request', err);
|
|
73
|
+
res.locals.report_error(err);
|
|
74
|
+
next(err);
|
|
75
|
+
}
|
|
71
76
|
});
|
|
72
77
|
}
|
|
73
78
|
//# sourceMappingURL=package.js.map
|
package/build/package.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"package.js","names":["debug","buildDebug","route","auth","storage","can","allow","get","req","_res","next","name","params","package","version","write","query","requestOptions","protocol","headers","host","remoteAddress","socket","byPassCache","manifest","getPackageByOptions","uplinksLook","err","res","pkg","filename","abort","AbortController","stream","getTarballNext","signal","on","size","header","HEADER_TYPE","CONTENT_LENGTH","once","locals","report_error","url","HEADERS","CONTENT_TYPE","OCTET_STREAM","pipe"],"sources":["../src/package.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\n\nimport { IAuth } from '@verdaccio/auth';\nimport { HEADERS, HEADER_TYPE } from '@verdaccio/core';\nimport { allow } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';\n\nconst debug = buildDebug('verdaccio:api:package');\n\nexport default function (route: Router, auth: IAuth, storage: Storage): void {\n const can = allow(auth);\n\n route.get(\n '/:package/:version?',\n can('access'),\n async function (\n req: $RequestExtend,\n _res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n debug('init package by version');\n const name = req.params.package;\n let version = req.params.version;\n const write = req.query.write === 'true';\n const requestOptions = {\n protocol: req.protocol,\n headers: req.headers as any,\n // FIXME: if we migrate to req.hostname, the port is not longer included.\n host: req.host,\n remoteAddress: req.socket.remoteAddress,\n byPassCache: write,\n };\n\n try {\n const manifest = await storage.getPackageByOptions({\n name,\n uplinksLook: true,\n version,\n requestOptions,\n });\n next(manifest);\n } catch (err) {\n next(err);\n }\n }\n );\n\n route.get(\n '/:pkg/-/:filename',\n can('access'),\n async function (req: $RequestExtend, res: $ResponseExtend, next): Promise<void> {\n const { pkg, filename } = req.params;\n const abort = new AbortController();\n try {\n const stream = (await storage.getTarballNext(pkg, filename, {\n signal: abort.signal,\n // enableRemote: true,\n })) as any;\n\n stream.on('content-length', (size) => {\n res.header(HEADER_TYPE.CONTENT_LENGTH, size);\n });\n\n stream.once('error', (err) => {\n res.locals.report_error(err);\n next(err);\n });\n\n req.on('abort', () => {\n debug('request aborted for %o', req.url);\n abort.abort();\n });\n\n res.header(HEADERS.CONTENT_TYPE, HEADERS.OCTET_STREAM);\n stream.pipe(res);\n } catch (err: any) {\n // console.log('catch API error request', err);\n res.locals.report_error(err);\n next(err);\n }\n }\n );\n}\n"],"mappings":";;;;;;;AAAA;;AAIA;;AACA;;;;AAKA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,uBAAX,CAAd;;AAEe,kBAAUC,KAAV,EAAyBC,IAAzB,EAAsCC,OAAtC,EAA8D;EAC3E,MAAMC,GAAG,GAAG,IAAAC,iBAAA,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K,MAAM,EAAEJ,KAAK,CAACI,MAD4C,CAE1D;;MAF0D,CAAtC,CAAtB;MAKAF,MAAM,CAACG,EAAP,CAAU,gBAAV,EAA6BC,IAAD,IAAU;QACpCT,GAAG,CAACU,MAAJ,CAAWC,iBAAA,CAAYC,cAAvB,EAAuCH,IAAvC;MACD,CAFD;MAIAJ,MAAM,CAACQ,IAAP,CAAY,OAAZ,EAAsBd,GAAD,IAAS;QAC5BC,GAAG,CAACc,MAAJ,CAAWC,YAAX,CAAwBhB,GAAxB;QACAjB,IAAI,CAACiB,GAAD,CAAJ;MACD,CAHD;MAKAnB,GAAG,CAAC4B,EAAJ,CAAO,OAAP,EAAgB,MAAM;QACpBpC,KAAK,CAAC,wBAAD,EAA2BQ,GAAG,CAACoC,GAA/B,CAAL;QACAb,KAAK,CAACA,KAAN;MACD,CAHD;MAKAH,GAAG,CAACU,MAAJ,CAAWO,aAAA,CAAQC,YAAnB,EAAiCD,aAAA,CAAQE,YAAzC;MACAd,MAAM,CAACe,IAAP,CAAYpB,GAAZ;IACD,CAtBD,CAsBE,OAAOD,GAAP,EAAiB;MACjB;MACAC,GAAG,CAACc,MAAJ,CAAWC,YAAX,CAAwBhB,GAAxB;MACAjB,IAAI,CAACiB,GAAD,CAAJ;IACD;EACF,CAjCH;AAmCD"}
|
package/build/ping.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"ping.js","names":["route","get","req","res","next"],"sources":["../src/ping.ts"],"sourcesContent":["import { Router } from 'express';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';\n\nexport default function (route: Router): void {\n route.get(\n '/-/ping',\n function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {\n next({});\n }\n );\n}\n"],"mappings":";;;;;;;AAIe,kBAAUA,KAAV,EAA+B;EAC5CA,KAAK,CAACC,GAAN,CACE,SADF,EAEE,UAAUC,GAAV,EAA+BC,GAA/B,EAAqDC,IAArD,EAA6E;IAC3EA,IAAI,CAAC,EAAD,CAAJ;EACD,CAJH;AAMD"}
|
package/build/publish.d.ts
CHANGED
|
@@ -1,26 +1,83 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
import { IAuth } from '@verdaccio/auth';
|
|
3
3
|
import { Storage } from '@verdaccio/store';
|
|
4
|
-
import { Config } from '@verdaccio/types';
|
|
5
|
-
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';
|
|
6
|
-
export default function publish(router: Router, auth: IAuth, storage: Storage, config: Config): void;
|
|
7
4
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
5
|
+
* Publish a package / update package / un/start a package
|
|
6
|
+
*
|
|
7
|
+
* There are multiples scenarios here to be considered:
|
|
8
|
+
*
|
|
9
|
+
* 1. Publish scenario
|
|
10
|
+
*
|
|
11
|
+
* Publish a package consist of at least 1 step (PUT) with a metadata payload.
|
|
12
|
+
* When a package is published, an _attachment property is present that contains the data
|
|
13
|
+
* of the tarball.
|
|
14
|
+
*
|
|
15
|
+
* Example flow of publish.
|
|
16
|
+
*
|
|
17
|
+
* npm http fetch PUT 201 http://localhost:4873/@scope%2ftest1 9627ms
|
|
18
|
+
npm info lifecycle @scope/test1@1.0.1~publish: @scope/test1@1.0.1
|
|
19
|
+
npm info lifecycle @scope/test1@1.0.1~postpublish: @scope/test1@1.0.1
|
|
20
|
+
+ @scope/test1@1.0.1
|
|
21
|
+
npm verb exit [ 0, true ]
|
|
22
|
+
*
|
|
23
|
+
*
|
|
24
|
+
* 2. Unpublish scenario
|
|
25
|
+
*
|
|
26
|
+
* Unpublish consist in 3 steps.
|
|
27
|
+
* 1. Try to fetch metadata -> if it fails, return 404
|
|
28
|
+
* 2. Compute metadata locally (client side) and send a mutate payload excluding the version to
|
|
29
|
+
* be unpublished
|
|
30
|
+
* eg: if metadata reflects 1.0.1, 1.0.2 and 1.0.3, the computed metadata won't include 1.0.3.
|
|
31
|
+
* 3. Once the second step has been successfully finished, delete the tarball.
|
|
32
|
+
*
|
|
33
|
+
* All these steps are consecutive and required, there is no transacions here, if step 3 fails,
|
|
34
|
+
* metadata might get corrupted.
|
|
35
|
+
*
|
|
36
|
+
* Note the unpublish call will suffix in the url a /-rev/14-5d500cfce92f90fd revision number,
|
|
37
|
+
* this not
|
|
38
|
+
* used internally.
|
|
39
|
+
*
|
|
40
|
+
*
|
|
41
|
+
* Example flow of unpublish.
|
|
42
|
+
*
|
|
43
|
+
* There are two possible flows:
|
|
44
|
+
*
|
|
45
|
+
* - Remove all pacakges (entirely)
|
|
46
|
+
* eg: npm unpublish package-name@* --force
|
|
47
|
+
* eg: npm unpublish package-name --force
|
|
48
|
+
*
|
|
49
|
+
* npm http fetch GET 200 http://localhost:4873/custom-name?write=true 1680ms
|
|
50
|
+
* npm http fetch DELETE 201 http://localhost:4873/custom-name/-/test1-1.0.3.tgz/-rev/16-e11c8db282b2d992 19ms
|
|
51
|
+
*
|
|
52
|
+
* - Remove a specific version
|
|
53
|
+
* eg: npm unpublish package-name@1.0.0 --force
|
|
54
|
+
*
|
|
55
|
+
* Get fresh manifest
|
|
56
|
+
* npm http fetch GET 200 http://localhost:4873/custom-name?write=true 1680ms
|
|
57
|
+
* Update manifest without the version to be unpublished
|
|
58
|
+
* npm http fetch PUT 201 http://localhost:4873/custom-name/-rev/14-5d500cfce92f90fd 956606ms
|
|
59
|
+
* Get fresh manifest (revision should be different)
|
|
60
|
+
* npm http fetch GET 200 http://localhost:4873/custom-name?write=true 1601ms
|
|
61
|
+
* Remove the tarball
|
|
62
|
+
* npm http fetch DELETE 201 http://localhost:4873/custom-name/-/test1-1.0.3.tgz/-rev/16-e11c8db282b2d992 19ms
|
|
63
|
+
*
|
|
64
|
+
* 3. Star a package
|
|
65
|
+
*
|
|
66
|
+
* Permissions: start a package depends of the publish and unpublish permissions, there is no
|
|
67
|
+
* specific flag for star or un start.
|
|
68
|
+
* The URL for star is similar to the unpublish (change package format)
|
|
69
|
+
*
|
|
70
|
+
* npm has no enpoint for star a package, rather mutate the metadata and acts as, the difference
|
|
71
|
+
* is the users property which is part of the payload and the body only includes
|
|
72
|
+
*
|
|
73
|
+
* {
|
|
74
|
+
"_id": pkgName,
|
|
75
|
+
"_rev": "3-b0cdaefc9bdb77c8",
|
|
76
|
+
"users": {
|
|
77
|
+
[username]: boolean value (true, false)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
*
|
|
81
|
+
*/
|
|
82
|
+
export default function publish(router: Router, auth: IAuth, storage: Storage): void;
|
|
83
|
+
export declare function publishPackageNext(storage: Storage): any;
|