@verdaccio/server 6.0.0-6-next.48 → 6.0.0-6-next.50
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 +38 -0
- package/build/server.js +2 -8
- package/build/server.js.map +1 -1
- package/package.json +13 -14
- package/src/server.ts +3 -10
- package/test/server.spec.ts +3 -3
- package/build/utils.d.ts +0 -1
- package/build/utils.js +0 -16
- package/build/utils.js.map +0 -1
- package/src/utils.ts +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @verdaccio/server
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.50
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [d167f92e]
|
|
8
|
+
- @verdaccio/config@6.0.0-6-next.61
|
|
9
|
+
- @verdaccio/api@6.0.0-6-next.44
|
|
10
|
+
- @verdaccio/auth@6.0.0-6-next.40
|
|
11
|
+
- @verdaccio/loaders@6.0.0-6-next.30
|
|
12
|
+
- @verdaccio/middleware@6.0.0-6-next.40
|
|
13
|
+
- verdaccio-audit@11.0.0-6-next.24
|
|
14
|
+
- @verdaccio/store@6.0.0-6-next.41
|
|
15
|
+
- @verdaccio/web@6.0.0-6-next.48
|
|
16
|
+
- @verdaccio/core@6.0.0-6-next.61
|
|
17
|
+
- @verdaccio/utils@6.0.0-6-next.29
|
|
18
|
+
- @verdaccio/logger@6.0.0-6-next.29
|
|
19
|
+
|
|
20
|
+
## 6.0.0-6-next.49
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- 45c03819: refactor: render html middleware
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [45c03819]
|
|
29
|
+
- @verdaccio/api@6.0.0-6-next.43
|
|
30
|
+
- @verdaccio/config@6.0.0-6-next.60
|
|
31
|
+
- @verdaccio/middleware@6.0.0-6-next.39
|
|
32
|
+
- verdaccio-audit@11.0.0-6-next.23
|
|
33
|
+
- @verdaccio/store@6.0.0-6-next.40
|
|
34
|
+
- @verdaccio/web@6.0.0-6-next.47
|
|
35
|
+
- @verdaccio/auth@6.0.0-6-next.39
|
|
36
|
+
- @verdaccio/loaders@6.0.0-6-next.29
|
|
37
|
+
- @verdaccio/core@6.0.0-6-next.60
|
|
38
|
+
- @verdaccio/logger@6.0.0-6-next.28
|
|
39
|
+
- @verdaccio/utils@6.0.0-6-next.28
|
|
40
|
+
|
|
3
41
|
## 6.0.0-6-next.48
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
package/build/server.js
CHANGED
|
@@ -8,7 +8,6 @@ var _compression = _interopRequireDefault(require("compression"));
|
|
|
8
8
|
var _cors = _interopRequireDefault(require("cors"));
|
|
9
9
|
var _debug = _interopRequireDefault(require("debug"));
|
|
10
10
|
var _express = _interopRequireDefault(require("express"));
|
|
11
|
-
var _expressRateLimit = _interopRequireDefault(require("express-rate-limit"));
|
|
12
11
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
12
|
var _verdaccioAudit = _interopRequireDefault(require("verdaccio-audit"));
|
|
14
13
|
var _api = _interopRequireDefault(require("@verdaccio/api"));
|
|
@@ -21,28 +20,23 @@ var _middleware = require("@verdaccio/middleware");
|
|
|
21
20
|
var _store = require("@verdaccio/store");
|
|
22
21
|
var _web = _interopRequireDefault(require("@verdaccio/web"));
|
|
23
22
|
var _debug2 = _interopRequireDefault(require("./debug"));
|
|
24
|
-
var _utils = require("./utils");
|
|
25
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
24
|
const debug = (0, _debug.default)('verdaccio:server');
|
|
27
25
|
const defineAPI = async function (config, storage) {
|
|
28
26
|
const auth = new _auth.Auth(config);
|
|
29
27
|
await auth.init();
|
|
30
28
|
const app = (0, _express.default)();
|
|
31
|
-
const limiter = new _expressRateLimit.default(config.serverSettings.rateLimit);
|
|
32
29
|
// run in production mode by default, just in case
|
|
33
30
|
// it shouldn't make any difference anyway
|
|
34
31
|
app.set('env', process.env.NODE_ENV || 'production');
|
|
35
32
|
app.use((0, _cors.default)());
|
|
36
|
-
app.use(
|
|
33
|
+
app.use((0, _middleware.rateLimit)(config.serverSettings.rateLimit));
|
|
37
34
|
const errorReportingMiddlewareWrap = (0, _middleware.errorReportingMiddleware)(_logger.logger);
|
|
38
35
|
|
|
39
36
|
// Router setup
|
|
40
37
|
app.use((0, _middleware.log)(_logger.logger));
|
|
41
38
|
app.use(errorReportingMiddlewareWrap);
|
|
42
|
-
app.use(
|
|
43
|
-
res.setHeader('x-powered-by', (0, _utils.getUserAgent)(config.user_agent));
|
|
44
|
-
next();
|
|
45
|
-
});
|
|
39
|
+
app.use((0, _middleware.userAgent)(config));
|
|
46
40
|
app.use((0, _compression.default)());
|
|
47
41
|
app.get('/favicon.ico', function (req, res, next) {
|
|
48
42
|
req.url = '/-/static/favicon.png';
|
package/build/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":["debug","buildDebug","defineAPI","config","storage","auth","Auth","init","app","express","
|
|
1
|
+
{"version":3,"file":"server.js","names":["debug","buildDebug","defineAPI","config","storage","auth","Auth","init","app","express","set","process","env","NODE_ENV","use","cors","rateLimit","serverSettings","errorReportingMiddlewareWrap","errorReportingMiddleware","logger","log","userAgent","compression","get","req","res","next","url","_debug","hookDebug","configPath","plugins","asyncLoadPlugin","middlewares","plugin","register_middlewares","length","info","push","AuditMiddleware","enabled","strict_ssl","forEach","apiEndpoint","_","webMiddleware","errorUtils","getNotFound","API_ERROR","WEB_DISABLED","err","isError","code","statusCode","HTTP_STATUS","NOT_MODIFIED","isFunction","locals","report_error","noop","final","startServer","configHash","AppConfig","Storage","error","msg","Error"],"sources":["../src/server.ts"],"sourcesContent":["import compression from 'compression';\nimport cors from 'cors';\nimport buildDebug from 'debug';\nimport express from 'express';\nimport { HttpError } from 'http-errors';\nimport _ from 'lodash';\nimport AuditMiddleware from 'verdaccio-audit';\n\nimport apiEndpoint from '@verdaccio/api';\nimport { Auth } from '@verdaccio/auth';\nimport { Config as AppConfig } from '@verdaccio/config';\nimport { API_ERROR, HTTP_STATUS, errorUtils, pluginUtils } from '@verdaccio/core';\nimport { asyncLoadPlugin } from '@verdaccio/loaders';\nimport { logger } from '@verdaccio/logger';\nimport { errorReportingMiddleware, final, log, rateLimit, userAgent } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { ConfigYaml } from '@verdaccio/types';\nimport { Config as IConfig } from '@verdaccio/types';\nimport webMiddleware from '@verdaccio/web';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';\nimport hookDebug from './debug';\n\nconst debug = buildDebug('verdaccio:server');\n\nconst defineAPI = async function (config: IConfig, storage: Storage): Promise<any> {\n const auth: Auth = new Auth(config);\n await auth.init();\n const app = express();\n // run in production mode by default, just in case\n // it shouldn't make any difference anyway\n app.set('env', process.env.NODE_ENV || 'production');\n app.use(cors());\n app.use(rateLimit(config.serverSettings.rateLimit));\n\n const errorReportingMiddlewareWrap = errorReportingMiddleware(logger);\n\n // Router setup\n app.use(log(logger));\n app.use(errorReportingMiddlewareWrap);\n app.use(userAgent(config));\n app.use(compression());\n\n app.get(\n '/favicon.ico',\n function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n req.url = '/-/static/favicon.png';\n next();\n }\n );\n\n // Hook for tests only\n if (config._debug) {\n hookDebug(app, config.configPath);\n }\n\n const plugins: pluginUtils.ExpressMiddleware<IConfig, {}, Auth>[] = await asyncLoadPlugin(\n config.middlewares,\n {\n config,\n logger,\n },\n function (plugin) {\n return typeof plugin.register_middlewares !== 'undefined';\n }\n );\n\n if (plugins.length === 0) {\n logger.info('none middleware plugins has been defined, adding audit middleware by default');\n // @ts-ignore\n plugins.push(new AuditMiddleware({ enabled: true, strict_ssl: true }, { config, logger }));\n }\n\n plugins.forEach((plugin: pluginUtils.ExpressMiddleware<IConfig, {}, Auth>) => {\n plugin.register_middlewares(app, auth, storage);\n });\n\n // For npm request\n // @ts-ignore\n app.use(apiEndpoint(config, auth, storage));\n\n // For WebUI & WebUI API\n if (_.get(config, 'web.enable', true)) {\n app.use(await webMiddleware(config, auth, storage));\n } else {\n app.get('/', function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {\n next(errorUtils.getNotFound(API_ERROR.WEB_DISABLED));\n });\n }\n\n // Catch 404\n app.get('/*', function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {\n next(errorUtils.getNotFound('resource not found'));\n });\n\n app.use(function (\n err: HttpError,\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ) {\n if (_.isError(err)) {\n if (err.code === 'ECONNABORT' && res.statusCode === HTTP_STATUS.NOT_MODIFIED) {\n return next();\n }\n if (_.isFunction(res.locals.report_error) === false) {\n // in case of very early error this middleware may not be loaded before error is generated\n // fixing that\n errorReportingMiddlewareWrap(req, res, _.noop);\n }\n res.locals.report_error(err);\n } else {\n // Fall to Middleware.final\n return next(err);\n }\n });\n\n app.use(final);\n\n return app;\n};\n\nexport default (async function startServer(configHash: ConfigYaml): Promise<any> {\n debug('start server');\n const config: IConfig = new AppConfig({ ...configHash } as any);\n // register middleware plugins\n debug('loaded filter plugin');\n // @ts-ignore\n const storage: Storage = new Storage(config);\n try {\n // waits until init calls have been initialized\n debug('storage init start');\n await storage.init(config);\n debug('storage init end');\n } catch (err: any) {\n logger.error({ error: err.msg }, 'storage has failed: @{error}');\n throw new Error(err);\n }\n return await defineAPI(config, storage);\n});\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAGA;AAAgC;AAEhC,MAAMA,KAAK,GAAG,IAAAC,cAAU,EAAC,kBAAkB,CAAC;AAE5C,MAAMC,SAAS,GAAG,gBAAgBC,MAAe,EA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AEC,OAAO,CAAC;AACzC,CAAC;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/server",
|
|
3
|
-
"version": "6.0.0-6-next.
|
|
3
|
+
"version": "6.0.0-6-next.50",
|
|
4
4
|
"description": "server logic",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -30,27 +30,26 @@
|
|
|
30
30
|
"npm": ">=6"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@verdaccio/api": "6.0.0-6-next.
|
|
34
|
-
"@verdaccio/auth": "6.0.0-6-next.
|
|
35
|
-
"@verdaccio/core": "6.0.0-6-next.
|
|
36
|
-
"@verdaccio/config": "6.0.0-6-next.
|
|
37
|
-
"@verdaccio/loaders": "6.0.0-6-next.
|
|
38
|
-
"@verdaccio/logger": "6.0.0-6-next.
|
|
39
|
-
"@verdaccio/middleware": "6.0.0-6-next.
|
|
40
|
-
"@verdaccio/store": "6.0.0-6-next.
|
|
41
|
-
"@verdaccio/utils": "6.0.0-6-next.
|
|
42
|
-
"@verdaccio/web": "6.0.0-6-next.
|
|
43
|
-
"verdaccio-audit": "11.0.0-6-next.
|
|
33
|
+
"@verdaccio/api": "6.0.0-6-next.44",
|
|
34
|
+
"@verdaccio/auth": "6.0.0-6-next.40",
|
|
35
|
+
"@verdaccio/core": "6.0.0-6-next.61",
|
|
36
|
+
"@verdaccio/config": "6.0.0-6-next.61",
|
|
37
|
+
"@verdaccio/loaders": "6.0.0-6-next.30",
|
|
38
|
+
"@verdaccio/logger": "6.0.0-6-next.29",
|
|
39
|
+
"@verdaccio/middleware": "6.0.0-6-next.40",
|
|
40
|
+
"@verdaccio/store": "6.0.0-6-next.41",
|
|
41
|
+
"@verdaccio/utils": "6.0.0-6-next.29",
|
|
42
|
+
"@verdaccio/web": "6.0.0-6-next.48",
|
|
43
|
+
"verdaccio-audit": "11.0.0-6-next.24",
|
|
44
44
|
"compression": "1.7.4",
|
|
45
45
|
"cors": "2.8.5",
|
|
46
46
|
"debug": "4.3.4",
|
|
47
47
|
"express": "4.18.2",
|
|
48
|
-
"express-rate-limit": "5.5.1",
|
|
49
48
|
"lodash": "4.17.21"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
51
|
"@types/node": "16.18.10",
|
|
53
|
-
"@verdaccio/proxy": "6.0.0-6-next.
|
|
52
|
+
"@verdaccio/proxy": "6.0.0-6-next.39",
|
|
54
53
|
"@verdaccio/test-helper": "2.0.0-6-next.7",
|
|
55
54
|
"http-errors": "1.8.1"
|
|
56
55
|
},
|
package/src/server.ts
CHANGED
|
@@ -2,7 +2,6 @@ import compression from 'compression';
|
|
|
2
2
|
import cors from 'cors';
|
|
3
3
|
import buildDebug from 'debug';
|
|
4
4
|
import express from 'express';
|
|
5
|
-
import RateLimit from 'express-rate-limit';
|
|
6
5
|
import { HttpError } from 'http-errors';
|
|
7
6
|
import _ from 'lodash';
|
|
8
7
|
import AuditMiddleware from 'verdaccio-audit';
|
|
@@ -13,7 +12,7 @@ import { Config as AppConfig } from '@verdaccio/config';
|
|
|
13
12
|
import { API_ERROR, HTTP_STATUS, errorUtils, pluginUtils } from '@verdaccio/core';
|
|
14
13
|
import { asyncLoadPlugin } from '@verdaccio/loaders';
|
|
15
14
|
import { logger } from '@verdaccio/logger';
|
|
16
|
-
import { errorReportingMiddleware, final, log } from '@verdaccio/middleware';
|
|
15
|
+
import { errorReportingMiddleware, final, log, rateLimit, userAgent } from '@verdaccio/middleware';
|
|
17
16
|
import { Storage } from '@verdaccio/store';
|
|
18
17
|
import { ConfigYaml } from '@verdaccio/types';
|
|
19
18
|
import { Config as IConfig } from '@verdaccio/types';
|
|
@@ -21,7 +20,6 @@ import webMiddleware from '@verdaccio/web';
|
|
|
21
20
|
|
|
22
21
|
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';
|
|
23
22
|
import hookDebug from './debug';
|
|
24
|
-
import { getUserAgent } from './utils';
|
|
25
23
|
|
|
26
24
|
const debug = buildDebug('verdaccio:server');
|
|
27
25
|
|
|
@@ -29,23 +27,18 @@ const defineAPI = async function (config: IConfig, storage: Storage): Promise<an
|
|
|
29
27
|
const auth: Auth = new Auth(config);
|
|
30
28
|
await auth.init();
|
|
31
29
|
const app = express();
|
|
32
|
-
const limiter = new RateLimit(config.serverSettings.rateLimit);
|
|
33
30
|
// run in production mode by default, just in case
|
|
34
31
|
// it shouldn't make any difference anyway
|
|
35
32
|
app.set('env', process.env.NODE_ENV || 'production');
|
|
36
33
|
app.use(cors());
|
|
37
|
-
app.use(
|
|
34
|
+
app.use(rateLimit(config.serverSettings.rateLimit));
|
|
38
35
|
|
|
39
36
|
const errorReportingMiddlewareWrap = errorReportingMiddleware(logger);
|
|
40
37
|
|
|
41
38
|
// Router setup
|
|
42
39
|
app.use(log(logger));
|
|
43
40
|
app.use(errorReportingMiddlewareWrap);
|
|
44
|
-
app.use(
|
|
45
|
-
res.setHeader('x-powered-by', getUserAgent(config.user_agent));
|
|
46
|
-
next();
|
|
47
|
-
});
|
|
48
|
-
|
|
41
|
+
app.use(userAgent(config));
|
|
49
42
|
app.use(compression());
|
|
50
43
|
|
|
51
44
|
app.get(
|
package/test/server.spec.ts
CHANGED
|
@@ -55,15 +55,15 @@ test('should contains etag', async () => {
|
|
|
55
55
|
expect(typeof etag === 'string').toBeTruthy();
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
test('should
|
|
58
|
+
test('should be hidden by default', async () => {
|
|
59
59
|
const app = await initializeServer('conf.yaml');
|
|
60
60
|
const response = await supertest(app)
|
|
61
61
|
.get('/')
|
|
62
62
|
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8)
|
|
63
63
|
.expect(HTTP_STATUS.OK);
|
|
64
64
|
const powered = response.get('x-powered-by');
|
|
65
|
-
expect(powered).toMatch('
|
|
66
|
-
});
|
|
65
|
+
expect(powered).toMatch('hidden');
|
|
66
|
+
}, 40000);
|
|
67
67
|
|
|
68
68
|
test('should not contains powered header', async () => {
|
|
69
69
|
const app = await initializeServer('powered-disabled.yaml');
|
package/build/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getUserAgent(userAgent: string): string;
|
package/build/utils.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getUserAgent = getUserAgent;
|
|
7
|
-
const pkgVersion = require('../package.json').version;
|
|
8
|
-
function getUserAgent(userAgent) {
|
|
9
|
-
if (typeof userAgent === 'string') {
|
|
10
|
-
return userAgent;
|
|
11
|
-
} else if (userAgent === false) {
|
|
12
|
-
return 'hidden';
|
|
13
|
-
}
|
|
14
|
-
return `verdaccio/${pkgVersion}`;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=utils.js.map
|
package/build/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["pkgVersion","require","version","getUserAgent","userAgent"],"sources":["../src/utils.ts"],"sourcesContent":["const pkgVersion = require('../package.json').version;\n\nexport function getUserAgent(userAgent: string): string {\n if (typeof userAgent === 'string') {\n return userAgent;\n } else if (userAgent === false) {\n return 'hidden';\n }\n\n return `verdaccio/${pkgVersion}`;\n}\n"],"mappings":";;;;;;AAAA,MAAMA,UAAU,GAAGC,OAAO,CAAC,iBAAiB,CAAC,CAACC,OAAO;AAE9C,SAASC,YAAY,CAACC,SAAiB,EAAU;EACtD,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE;IACjC,OAAOA,SAAS;EAClB,CAAC,MAAM,IAAIA,SAAS,KAAK,KAAK,EAAE;IAC9B,OAAO,QAAQ;EACjB;EAEA,OAAQ,aAAYJ,UAAW,EAAC;AAClC"}
|
package/src/utils.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const pkgVersion = require('../package.json').version;
|
|
2
|
-
|
|
3
|
-
export function getUserAgent(userAgent: string): string {
|
|
4
|
-
if (typeof userAgent === 'string') {
|
|
5
|
-
return userAgent;
|
|
6
|
-
} else if (userAgent === false) {
|
|
7
|
-
return 'hidden';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return `verdaccio/${pkgVersion}`;
|
|
11
|
-
}
|