@verdaccio/config 6.0.0-6-next.58 → 6.0.0-6-next.60
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 +18 -0
- package/build/agent.d.ts +1 -1
- package/build/agent.js +11 -3
- package/build/agent.js.map +1 -1
- package/build/config.d.ts +7 -2
- package/build/config.js +19 -6
- package/build/config.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +12 -0
- package/build/index.js.map +1 -1
- package/package.json +3 -3
- package/src/agent.ts +15 -3
- package/src/config.ts +16 -5
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @verdaccio/config
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.60
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 45c03819: refactor: render html middleware
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- @verdaccio/core@6.0.0-6-next.60
|
|
12
|
+
- @verdaccio/utils@6.0.0-6-next.28
|
|
13
|
+
|
|
14
|
+
## 6.0.0-6-next.59
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- @verdaccio/core@6.0.0-6-next.59
|
|
19
|
+
- @verdaccio/utils@6.0.0-6-next.27
|
|
20
|
+
|
|
3
21
|
## 6.0.0-6-next.58
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/build/agent.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getUserAgent(): string;
|
|
1
|
+
export declare function getUserAgent(customUserAgent?: boolean | string, version?: string, name?: string): string;
|
package/build/agent.js
CHANGED
|
@@ -4,8 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getUserAgent = getUserAgent;
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
7
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
function getUserAgent(customUserAgent, version, name) {
|
|
10
|
+
if (customUserAgent === true) {
|
|
11
|
+
return `${name}/${version}`;
|
|
12
|
+
} else if (_lodash.default.isString(customUserAgent) && _lodash.default.isEmpty(customUserAgent) === false) {
|
|
13
|
+
return customUserAgent;
|
|
14
|
+
} else if (customUserAgent === false) {
|
|
15
|
+
return 'hidden';
|
|
16
|
+
}
|
|
17
|
+
return `${name}/${version}`;
|
|
10
18
|
}
|
|
11
19
|
//# sourceMappingURL=agent.js.map
|
package/build/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","names":["
|
|
1
|
+
{"version":3,"file":"agent.js","names":["getUserAgent","customUserAgent","version","name","_","isString","isEmpty"],"sources":["../src/agent.ts"],"sourcesContent":["import _ from 'lodash';\n\nexport function getUserAgent(\n customUserAgent?: boolean | string,\n version?: string,\n name?: string\n): string {\n if (customUserAgent === true) {\n return `${name}/${version}`;\n } else if (_.isString(customUserAgent) && _.isEmpty(customUserAgent) === false) {\n return customUserAgent;\n } else if (customUserAgent === false) {\n return 'hidden';\n }\n\n return `${name}/${version}`;\n}\n"],"mappings":";;;;;;AAAA;AAAuB;AAEhB,SAASA,YAAY,CAC1BC,eAAkC,EAClCC,OAAgB,EAChBC,IAAa,EACL;EACR,IAAIF,eAAe,KAAK,IAAI,EAAE;IAC5B,OAAQ,GAAEE,IAAK,IAAGD,OAAQ,EAAC;EAC7B,CAAC,MAAM,IAAIE,eAAC,CAACC,QAAQ,CAACJ,eAAe,CAAC,IAAIG,eAAC,CAACE,OAAO,CAACL,eAAe,CAAC,KAAK,KAAK,EAAE;IAC9E,OAAOA,eAAe;EACxB,CAAC,MAAM,IAAIA,eAAe,KAAK,KAAK,EAAE;IACpC,OAAO,QAAQ;EACjB;EAEA,OAAQ,GAAEE,IAAK,IAAGD,OAAQ,EAAC;AAC7B"}
|
package/build/config.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { Config as AppConfig, AuthConf, ConfigYaml, FlagsConfig, PackageAccess, PackageList, Security, ServerSettingsConf } from '@verdaccio/types';
|
|
1
|
+
import { Config as AppConfig, AuthConf, ConfigYaml, FlagsConfig, PackageAccess, PackageList, RateLimit, Security, ServerSettingsConf } from '@verdaccio/types';
|
|
2
2
|
export declare const WEB_TITLE = "Verdaccio";
|
|
3
|
+
export declare const defaultUserRateLimiting: {
|
|
4
|
+
windowMs: number;
|
|
5
|
+
max: number;
|
|
6
|
+
};
|
|
3
7
|
/**
|
|
4
8
|
* Coordinates the application configuration
|
|
5
9
|
*/
|
|
6
10
|
declare class Config implements AppConfig {
|
|
7
|
-
user_agent: string;
|
|
11
|
+
user_agent: string | undefined;
|
|
8
12
|
uplinks: any;
|
|
9
13
|
packages: PackageList;
|
|
10
14
|
users: any;
|
|
@@ -18,6 +22,7 @@ declare class Config implements AppConfig {
|
|
|
18
22
|
serverSettings: ServerSettingsConf;
|
|
19
23
|
secret: string;
|
|
20
24
|
flags: FlagsConfig;
|
|
25
|
+
userRateLimit: RateLimit;
|
|
21
26
|
constructor(config: ConfigYaml & {
|
|
22
27
|
config_path: string;
|
|
23
28
|
});
|
package/build/config.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WEB_TITLE = exports.Config = void 0;
|
|
6
|
+
exports.defaultUserRateLimiting = exports.WEB_TITLE = exports.Config = void 0;
|
|
7
7
|
var _assert = _interopRequireDefault(require("assert"));
|
|
8
8
|
var _debug = _interopRequireDefault(require("debug"));
|
|
9
9
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
@@ -21,10 +21,18 @@ const allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];
|
|
|
21
21
|
const debug = (0, _debug.default)('verdaccio:config');
|
|
22
22
|
const WEB_TITLE = 'Verdaccio';
|
|
23
23
|
|
|
24
|
+
// we limit max 1000 request per 15 minutes on user endpoints
|
|
25
|
+
exports.WEB_TITLE = WEB_TITLE;
|
|
26
|
+
const defaultUserRateLimiting = {
|
|
27
|
+
windowMs: 15 * 60 * 1000,
|
|
28
|
+
// 15 minutes
|
|
29
|
+
max: 1000
|
|
30
|
+
};
|
|
31
|
+
|
|
24
32
|
/**
|
|
25
33
|
* Coordinates the application configuration
|
|
26
34
|
*/
|
|
27
|
-
exports.
|
|
35
|
+
exports.defaultUserRateLimiting = defaultUserRateLimiting;
|
|
28
36
|
class Config {
|
|
29
37
|
// @deprecated use configPath instead
|
|
30
38
|
|
|
@@ -46,16 +54,21 @@ class Config {
|
|
|
46
54
|
this.flags = {
|
|
47
55
|
searchRemote: (_config$flags$searchR = (_config$flags = config.flags) === null || _config$flags === void 0 ? void 0 : _config$flags.searchRemote) !== null && _config$flags$searchR !== void 0 ? _config$flags$searchR : true
|
|
48
56
|
};
|
|
57
|
+
this.user_agent = config.user_agent;
|
|
49
58
|
for (const configProp in config) {
|
|
50
59
|
if (self[configProp] == null) {
|
|
51
60
|
self[configProp] = config[configProp];
|
|
52
61
|
}
|
|
53
62
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.user_agent = (0, _agent.getUserAgent)();
|
|
63
|
+
if (typeof this.user_agent === 'undefined') {
|
|
64
|
+
// by default user agent is hidden
|
|
65
|
+
debug('set default user agent');
|
|
66
|
+
this.user_agent = (0, _agent.getUserAgent)(false);
|
|
58
67
|
}
|
|
68
|
+
this.userRateLimit = {
|
|
69
|
+
...defaultUserRateLimiting,
|
|
70
|
+
...(config === null || config === void 0 ? void 0 : config.userRateLimit)
|
|
71
|
+
};
|
|
59
72
|
|
|
60
73
|
// some weird shell scripts are valid yaml files parsed as string
|
|
61
74
|
(0, _assert.default)(_lodash.default.isObject(config), _core.APP_ERROR.CONFIG_NOT_VALID);
|
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["strategicConfigProps","allowedEnvConfig","debug","buildDebug","WEB_TITLE","Config","constructor","config","self","storage","process","env","VERDACCIO_STORAGE_PATH","configPath","Error","config_path","plugins","security","_","merge","defaultSecurity","serverSettings","flags","searchRemote","
|
|
1
|
+
{"version":3,"file":"config.js","names":["strategicConfigProps","allowedEnvConfig","debug","buildDebug","WEB_TITLE","defaultUserRateLimiting","windowMs","max","Config","constructor","config","self","storage","process","env","VERDACCIO_STORAGE_PATH","configPath","Error","config_path","plugins","security","_","merge","defaultSecurity","serverSettings","flags","searchRemote","user_agent","configProp","getUserAgent","userRateLimit","assert","isObject","APP_ERROR","CONFIG_NOT_VALID","forEach","x","uplinks","sanityCheckUplinksProps","uplinkSanityCheck","packages","normalisePackageAccess","envConf","toUpperCase","server_id","generateRandomHexString","getMatchedPackagesSpec","pkgName","checkSecretKey","secret","isString","isEmpty","generateRandomSecretKey"],"sources":["../src/config.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { APP_ERROR } from '@verdaccio/core';\nimport {\n Config as AppConfig,\n AuthConf,\n ConfigYaml,\n FlagsConfig,\n PackageAccess,\n PackageList,\n RateLimit,\n Security,\n ServerSettingsConf,\n} from '@verdaccio/types';\nimport { generateRandomHexString, getMatchedPackagesSpec, isObject } from '@verdaccio/utils';\n\nimport { getUserAgent } from './agent';\nimport { normalisePackageAccess } from './package-access';\nimport { defaultSecurity } from './security';\nimport serverSettings from './serverSettings';\nimport { generateRandomSecretKey } from './token';\nimport { sanityCheckUplinksProps, uplinkSanityCheck } from './uplinks';\n\nconst strategicConfigProps = ['uplinks', 'packages'];\nconst allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];\nconst debug = buildDebug('verdaccio:config');\n\nexport const WEB_TITLE = 'Verdaccio';\n\n// we limit max 1000 request per 15 minutes on user endpoints\nexport const defaultUserRateLimiting = {\n windowMs: 15 * 60 * 1000, // 15 minutes\n max: 1000,\n};\n\n/**\n * Coordinates the application configuration\n */\nclass Config implements AppConfig {\n public user_agent: string | undefined;\n public uplinks: any;\n public packages: PackageList;\n public users: any;\n public auth: AuthConf;\n public server_id: string;\n // @deprecated use configPath instead\n public config_path: string;\n public configPath: string;\n public storage: string | void;\n\n public plugins: string | void | null;\n public security: Security;\n public serverSettings: ServerSettingsConf;\n // @ts-ignore\n public secret: string;\n public flags: FlagsConfig;\n public userRateLimit: RateLimit;\n public constructor(config: ConfigYaml & { config_path: string }) {\n const self = this;\n this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;\n if (!config.configPath) {\n throw new Error('config_path is required');\n }\n this.config_path = config.config_path ?? (config.configPath as string);\n this.configPath = config.configPath;\n debug('config path: %s', this.configPath);\n this.plugins = config.plugins;\n this.security = _.merge(defaultSecurity, config.security);\n this.serverSettings = serverSettings;\n this.flags = {\n searchRemote: config.flags?.searchRemote ?? true,\n };\n this.user_agent = config.user_agent;\n\n for (const configProp in config) {\n if (self[configProp] == null) {\n self[configProp] = config[configProp];\n }\n }\n\n if (typeof this.user_agent === 'undefined') {\n // by default user agent is hidden\n debug('set default user agent');\n this.user_agent = getUserAgent(false);\n }\n\n this.userRateLimit = { ...defaultUserRateLimiting, ...config?.userRateLimit };\n\n // some weird shell scripts are valid yaml files parsed as string\n assert(_.isObject(config), APP_ERROR.CONFIG_NOT_VALID);\n\n // sanity check for strategic config properties\n strategicConfigProps.forEach(function (x): void {\n if (self[x] == null) {\n self[x] = {};\n }\n\n assert(isObject(self[x]), `CONFIG: bad \"${x}\" value (object expected)`);\n });\n\n this.uplinks = sanityCheckUplinksProps(uplinkSanityCheck(this.uplinks));\n this.packages = normalisePackageAccess(self.packages);\n\n // loading these from ENV if aren't in config\n allowedEnvConfig.forEach((envConf): void => {\n if (!(envConf in self)) {\n self[envConf] = process.env[envConf] || process.env[envConf.toUpperCase()];\n }\n });\n\n // unique identifier of self server (or a cluster), used to avoid loops\n // @ts-ignore\n if (!this.server_id) {\n this.server_id = generateRandomHexString(6);\n }\n }\n\n /**\n * Check for package spec\n */\n public getMatchedPackagesSpec(pkgName: string): PackageAccess | void {\n // TODO: remove this method and replace by library utils\n return getMatchedPackagesSpec(pkgName, this.packages);\n }\n\n /**\n * Store or create whether receive a secret key\n */\n public checkSecretKey(secret?: string): string {\n debug('check secret key');\n if (_.isString(secret) && _.isEmpty(secret) === false) {\n this.secret = secret;\n debug('reusing previous key');\n return secret;\n }\n // it generates a secret key\n // FUTURE: this might be an external secret key, perhaps within config file?\n debug('generate a new key');\n this.secret = generateRandomSecretKey();\n return this.secret;\n }\n}\n\nexport { Config };\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AAYA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAuE;AAEvE,MAAMA,oBAAoB,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC;AACpD,MAAMC,gBAAgB,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,UAAU,CAAC;AAClE,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,kBAAkB,CAAC;AAErC,MAAMC,SAAS,GAAG,WAAW;;AAEpC;AAAA;AACO,MAAMC,uBAAuB,GAAG;EACrCC,QAAQ,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;EAAE;EAC1BC,GAAG,EAAE;AACP,CAAC;;AAED;AACA;AACA;AAFA;AAGA,MAAMC,MAAM,CAAsB;EAOhC;;EAQA;;EAIOC,WAAW,CAACC,MAA4C,EAAE;IAAA;IAC/D,MAAMC,IAAI,GAAG,IAAI;IACjB,IAAI,CAACC,OAAO,GAAGC,OAAO,CAACC,GAAG,CAACC,sBAAsB,IAAIL,MAAM,CAACE,OAAO;IACnE,IAAI,CAACF,MAAM,CAACM,UAAU,EAAE;MACtB,MAAM,IAAIC,KAAK,CAAC,yBAAyB,CAAC;IAC5C;IACA,I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K,CAAC,oBAAoB,CAAC;IAC3B,IAAI,CAAC+C,MAAM,GAAG,IAAAG,8BAAuB,GAAE;IACvC,OAAO,IAAI,CAACH,MAAM;EACpB;AACF;AAAC"}
|
package/build/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './package-access';
|
|
|
5
5
|
export { fromJStoYAML, parseConfigFile } from './parse';
|
|
6
6
|
export * from './uplinks';
|
|
7
7
|
export * from './security';
|
|
8
|
+
export * from './agent';
|
|
8
9
|
export * from './user';
|
|
9
10
|
export { default as ConfigBuilder } from './builder';
|
|
10
11
|
export { getDefaultConfig } from './conf';
|
package/build/index.js
CHANGED
|
@@ -106,6 +106,18 @@ Object.keys(_security).forEach(function (key) {
|
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
});
|
|
109
|
+
var _agent = require("./agent");
|
|
110
|
+
Object.keys(_agent).forEach(function (key) {
|
|
111
|
+
if (key === "default" || key === "__esModule") return;
|
|
112
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
113
|
+
if (key in exports && exports[key] === _agent[key]) return;
|
|
114
|
+
Object.defineProperty(exports, key, {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function () {
|
|
117
|
+
return _agent[key];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
109
121
|
var _user = require("./user");
|
|
110
122
|
Object.keys(_user).forEach(function (key) {
|
|
111
123
|
if (key === "default" || key === "__esModule") return;
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from './config';\nexport * from './config-path';\nexport * from './token';\nexport * from './package-access';\nexport { fromJStoYAML, parseConfigFile } from './parse';\nexport * from './uplinks';\nexport * from './security';\nexport * from './user';\nexport { default as ConfigBuilder } from './builder';\nexport { getDefaultConfig } from './conf';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AACA;AAA0C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from './config';\nexport * from './config-path';\nexport * from './token';\nexport * from './package-access';\nexport { fromJStoYAML, parseConfigFile } from './parse';\nexport * from './uplinks';\nexport * from './security';\nexport * from './agent';\nexport * from './user';\nexport { default as ConfigBuilder } from './builder';\nexport { getDefaultConfig } from './conf';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AACA;AAA0C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/config",
|
|
3
|
-
"version": "6.0.0-6-next.
|
|
3
|
+
"version": "6.0.0-6-next.60",
|
|
4
4
|
"description": "logger",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"node": ">=12"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@verdaccio/core": "6.0.0-6-next.
|
|
33
|
-
"@verdaccio/utils": "6.0.0-6-next.
|
|
32
|
+
"@verdaccio/core": "6.0.0-6-next.60",
|
|
33
|
+
"@verdaccio/utils": "6.0.0-6-next.28",
|
|
34
34
|
"debug": "4.3.4",
|
|
35
35
|
"yaml": "2.2.0",
|
|
36
36
|
"lodash": "4.17.21",
|
package/src/agent.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import _ from 'lodash';
|
|
2
2
|
|
|
3
|
-
export function getUserAgent(
|
|
4
|
-
|
|
3
|
+
export function getUserAgent(
|
|
4
|
+
customUserAgent?: boolean | string,
|
|
5
|
+
version?: string,
|
|
6
|
+
name?: string
|
|
7
|
+
): string {
|
|
8
|
+
if (customUserAgent === true) {
|
|
9
|
+
return `${name}/${version}`;
|
|
10
|
+
} else if (_.isString(customUserAgent) && _.isEmpty(customUserAgent) === false) {
|
|
11
|
+
return customUserAgent;
|
|
12
|
+
} else if (customUserAgent === false) {
|
|
13
|
+
return 'hidden';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return `${name}/${version}`;
|
|
5
17
|
}
|
package/src/config.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
FlagsConfig,
|
|
11
11
|
PackageAccess,
|
|
12
12
|
PackageList,
|
|
13
|
+
RateLimit,
|
|
13
14
|
Security,
|
|
14
15
|
ServerSettingsConf,
|
|
15
16
|
} from '@verdaccio/types';
|
|
@@ -28,11 +29,17 @@ const debug = buildDebug('verdaccio:config');
|
|
|
28
29
|
|
|
29
30
|
export const WEB_TITLE = 'Verdaccio';
|
|
30
31
|
|
|
32
|
+
// we limit max 1000 request per 15 minutes on user endpoints
|
|
33
|
+
export const defaultUserRateLimiting = {
|
|
34
|
+
windowMs: 15 * 60 * 1000, // 15 minutes
|
|
35
|
+
max: 1000,
|
|
36
|
+
};
|
|
37
|
+
|
|
31
38
|
/**
|
|
32
39
|
* Coordinates the application configuration
|
|
33
40
|
*/
|
|
34
41
|
class Config implements AppConfig {
|
|
35
|
-
public user_agent: string;
|
|
42
|
+
public user_agent: string | undefined;
|
|
36
43
|
public uplinks: any;
|
|
37
44
|
public packages: PackageList;
|
|
38
45
|
public users: any;
|
|
@@ -49,7 +56,7 @@ class Config implements AppConfig {
|
|
|
49
56
|
// @ts-ignore
|
|
50
57
|
public secret: string;
|
|
51
58
|
public flags: FlagsConfig;
|
|
52
|
-
|
|
59
|
+
public userRateLimit: RateLimit;
|
|
53
60
|
public constructor(config: ConfigYaml & { config_path: string }) {
|
|
54
61
|
const self = this;
|
|
55
62
|
this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;
|
|
@@ -65,6 +72,7 @@ class Config implements AppConfig {
|
|
|
65
72
|
this.flags = {
|
|
66
73
|
searchRemote: config.flags?.searchRemote ?? true,
|
|
67
74
|
};
|
|
75
|
+
this.user_agent = config.user_agent;
|
|
68
76
|
|
|
69
77
|
for (const configProp in config) {
|
|
70
78
|
if (self[configProp] == null) {
|
|
@@ -72,11 +80,14 @@ class Config implements AppConfig {
|
|
|
72
80
|
}
|
|
73
81
|
}
|
|
74
82
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
if (typeof this.user_agent === 'undefined') {
|
|
84
|
+
// by default user agent is hidden
|
|
85
|
+
debug('set default user agent');
|
|
86
|
+
this.user_agent = getUserAgent(false);
|
|
78
87
|
}
|
|
79
88
|
|
|
89
|
+
this.userRateLimit = { ...defaultUserRateLimiting, ...config?.userRateLimit };
|
|
90
|
+
|
|
80
91
|
// some weird shell scripts are valid yaml files parsed as string
|
|
81
92
|
assert(_.isObject(config), APP_ERROR.CONFIG_NOT_VALID);
|
|
82
93
|
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './package-access';
|
|
|
5
5
|
export { fromJStoYAML, parseConfigFile } from './parse';
|
|
6
6
|
export * from './uplinks';
|
|
7
7
|
export * from './security';
|
|
8
|
+
export * from './agent';
|
|
8
9
|
export * from './user';
|
|
9
10
|
export { default as ConfigBuilder } from './builder';
|
|
10
11
|
export { getDefaultConfig } from './conf';
|