@verdaccio/config 7.0.0-next.3 → 7.0.0-next.5
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 +26 -7
- package/build/config.d.ts +1 -0
- package/build/config.js +30 -17
- package/build/config.js.map +1 -1
- package/build/package-access.js +2 -4
- package/build/package-access.js.map +1 -1
- package/build/security.js +2 -4
- package/build/security.js.map +1 -1
- package/build/serverSettings.js +1 -2
- package/build/serverSettings.js.map +1 -1
- package/build/token.js +1 -2
- package/build/token.js.map +1 -1
- package/build/uplinks.js +2 -4
- package/build/uplinks.js.map +1 -1
- package/build/user.js +2 -4
- package/build/user.js.map +1 -1
- package/package.json +4 -4
- package/src/config.ts +27 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @verdaccio/config
|
|
2
2
|
|
|
3
|
+
## 7.0.0-next.5
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f047cc8: refactor: auth with legacy sign support
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [f047cc8]
|
|
12
|
+
- @verdaccio/core@7.0.0-next.5
|
|
13
|
+
- @verdaccio/utils@7.0.0-next.5
|
|
14
|
+
|
|
15
|
+
## 7.0.0-next.4
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- @verdaccio/core@7.0.0-next.4
|
|
20
|
+
- @verdaccio/utils@7.0.0-next.4
|
|
21
|
+
|
|
3
22
|
## 7.0.0-next.3
|
|
4
23
|
|
|
5
24
|
### Major Changes
|
|
@@ -218,12 +237,12 @@
|
|
|
218
237
|
- 8f43bf17d: feat: node api new structure based on promise
|
|
219
238
|
|
|
220
239
|
```js
|
|
221
|
-
import { runServer } from
|
|
240
|
+
import { runServer } from "@verdaccio/node-api";
|
|
222
241
|
// or
|
|
223
|
-
import { runServer } from
|
|
242
|
+
import { runServer } from "verdaccio";
|
|
224
243
|
|
|
225
244
|
const app = await runServer(); // default configuration
|
|
226
|
-
const app = await runServer(
|
|
245
|
+
const app = await runServer("./config/config.yaml");
|
|
227
246
|
const app = await runServer({ configuration });
|
|
228
247
|
app.listen(4000, (event) => {
|
|
229
248
|
// do something
|
|
@@ -993,14 +1012,14 @@
|
|
|
993
1012
|
- 5c5057fc: feat: node api new structure based on promise
|
|
994
1013
|
|
|
995
1014
|
```js
|
|
996
|
-
import { runServer } from
|
|
1015
|
+
import { runServer } from "@verdaccio/node-api";
|
|
997
1016
|
// or
|
|
998
|
-
import { runServer } from
|
|
1017
|
+
import { runServer } from "verdaccio";
|
|
999
1018
|
|
|
1000
1019
|
const app = await runServer(); // default configuration
|
|
1001
|
-
const app = await runServer(
|
|
1020
|
+
const app = await runServer("./config/config.yaml");
|
|
1002
1021
|
const app = await runServer({ configuration });
|
|
1003
|
-
app.listen(4000, event => {
|
|
1022
|
+
app.listen(4000, (event) => {
|
|
1004
1023
|
// do something
|
|
1005
1024
|
});
|
|
1006
1025
|
```
|
package/build/config.d.ts
CHANGED
package/build/config.js
CHANGED
|
@@ -20,11 +20,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
20
20
|
const strategicConfigProps = ['uplinks', 'packages'];
|
|
21
21
|
const allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];
|
|
22
22
|
const debug = (0, _debug.default)('verdaccio:config');
|
|
23
|
-
const WEB_TITLE = 'Verdaccio';
|
|
23
|
+
const WEB_TITLE = exports.WEB_TITLE = 'Verdaccio';
|
|
24
24
|
|
|
25
25
|
// we limit max 1000 request per 15 minutes on user endpoints
|
|
26
|
-
exports.
|
|
27
|
-
const defaultUserRateLimiting = {
|
|
26
|
+
const defaultUserRateLimiting = exports.defaultUserRateLimiting = {
|
|
28
27
|
windowMs: 15 * 60 * 1000,
|
|
29
28
|
// 15 minutes
|
|
30
29
|
max: 1000
|
|
@@ -33,7 +32,6 @@ const defaultUserRateLimiting = {
|
|
|
33
32
|
/**
|
|
34
33
|
* Coordinates the application configuration
|
|
35
34
|
*/
|
|
36
|
-
exports.defaultUserRateLimiting = defaultUserRateLimiting;
|
|
37
35
|
class Config {
|
|
38
36
|
/**
|
|
39
37
|
* @deprecated use configPath or config.getConfigPath();
|
|
@@ -41,7 +39,12 @@ class Config {
|
|
|
41
39
|
|
|
42
40
|
// @ts-ignore
|
|
43
41
|
|
|
44
|
-
constructor(config,
|
|
42
|
+
constructor(config,
|
|
43
|
+
// forceEnhancedLegacySignature is a property that
|
|
44
|
+
// allows switch a new legacy aes signature token signature
|
|
45
|
+
// for older versions do not want to have this new signature model
|
|
46
|
+
// this property must be false
|
|
47
|
+
configOptions = {
|
|
45
48
|
forceEnhancedLegacySignature: true
|
|
46
49
|
}) {
|
|
47
50
|
var _config$flags$searchR, _config$flags, _config$flags$changeP, _config$flags2;
|
|
@@ -109,6 +112,15 @@ class Config {
|
|
|
109
112
|
this.server_id = (0, _utils.generateRandomHexString)(6);
|
|
110
113
|
}
|
|
111
114
|
}
|
|
115
|
+
getEnhancedLegacySignature() {
|
|
116
|
+
if (typeof (this === null || this === void 0 ? void 0 : this.security.enhancedLegacySignature) !== 'undefined') {
|
|
117
|
+
if (this.security.enhancedLegacySignature === true) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return this.configOptions.forceEnhancedLegacySignature;
|
|
123
|
+
}
|
|
112
124
|
getConfigPath() {
|
|
113
125
|
return this.configPath;
|
|
114
126
|
}
|
|
@@ -126,7 +138,7 @@ class Config {
|
|
|
126
138
|
* @secret external secret key
|
|
127
139
|
*/
|
|
128
140
|
checkSecretKey(secret) {
|
|
129
|
-
var _this$secret;
|
|
141
|
+
var _this$security, _this$secret;
|
|
130
142
|
debug('check secret key');
|
|
131
143
|
if (typeof secret === 'string' && _lodash.default.isEmpty(secret) === false) {
|
|
132
144
|
this.secret = secret;
|
|
@@ -135,20 +147,21 @@ class Config {
|
|
|
135
147
|
}
|
|
136
148
|
// generate a new a secret key
|
|
137
149
|
// FUTURE: this might be an external secret key, perhaps within config file?
|
|
138
|
-
debug('
|
|
139
|
-
|
|
140
|
-
|
|
150
|
+
debug('generating a new secret key');
|
|
151
|
+
if (this.getEnhancedLegacySignature()) {
|
|
152
|
+
debug('key generated with "enhanced" legacy signature user config');
|
|
141
153
|
this.secret = (0, _token.generateRandomSecretKey)();
|
|
142
154
|
} else {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
155
|
+
debug('key generated with legacy signature user config');
|
|
156
|
+
this.secret = (0, _utils.generateRandomHexString)(32);
|
|
157
|
+
}
|
|
158
|
+
// set this to false allow use old token signature and is not recommended
|
|
159
|
+
// only use for migration reasons, major release will remove this property and
|
|
160
|
+
// set it by default
|
|
161
|
+
if (((_this$security = this.security) === null || _this$security === void 0 ? void 0 : _this$security.enhancedLegacySignature) === false) {
|
|
162
|
+
_core.warningUtils.emit(_warningUtils.Codes.VERWAR005);
|
|
150
163
|
}
|
|
151
|
-
debug('generated a new secret key %s', (_this$secret = this.secret) === null || _this$secret === void 0 ? void 0 : _this$secret.length);
|
|
164
|
+
debug('generated a new secret key length %s', (_this$secret = this.secret) === null || _this$secret === void 0 ? void 0 : _this$secret.length);
|
|
152
165
|
return this.secret;
|
|
153
166
|
}
|
|
154
167
|
}
|
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["_assert","_interopRequireDefault","require","_debug","_lodash","_core","_warningUtils","_utils","_agent","_packageAccess","_security","_serverSettings","_token","_uplinks","obj","__esModule","default","strategicConfigProps","allowedEnvConfig","debug","buildDebug","WEB_TITLE","exports","defaultUserRateLimiting","windowMs","max","Config","constructor","config","configOptions","forceEnhancedLegacySignature","_config$flags$searchR","_config$flags","_config$flags$changeP","_config$flags2","self","storage","process","env","VERDACCIO_STORAGE_PATH","configPath","_config$config_path","config_path","self_path","Error","plugins","security","_","merge","defaultSecurity","serverSettings","flags","searchRemote","changePassword","user_agent","configProp","getUserAgent","userRateLimit","assert","isObject","APP_ERROR","CONFIG_NOT_VALID","forEach","x","uplinks","sanityCheckUplinksProps","uplinkSanityCheck","packages","normalisePackageAccess","envConf","toUpperCase","server_id","generateRandomHexString","getConfigPath","getMatchedPackagesSpec","pkgName","checkSecretKey","secret","_this$secret","isEmpty","generateRandomSecretKey","enhancedLegacySignature","warningUtils","emit","Codes","VERWAR005","length"],"sources":["../src/config.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { APP_ERROR, warningUtils } from '@verdaccio/core';\nimport { Codes } from '@verdaccio/core/build/warning-utils';\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 public configPath: string;\n /**\n * @deprecated use configPath or config.getConfigPath();\n */\n public self_path: 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 private configOptions: { forceEnhancedLegacySignature: boolean };\n public constructor(\n config: ConfigYaml & { config_path: string },\n configOptions = { forceEnhancedLegacySignature: true }\n ) {\n const self = this;\n this.configOptions = configOptions;\n this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;\n if (!config.configPath) {\n // backport self_path for previous to version 6\n // @ts-expect-error\n config.configPath = config.config_path ?? config.self_path;\n if (!config.configPath) {\n throw new Error('configPath property is required');\n }\n }\n this.configPath = config.configPath;\n this.self_path = this.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 changePassword: config.flags?.changePassword ?? false,\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 public getConfigPath() {\n return this.configPath;\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 * @secret external secret key\n */\n public checkSecretKey(secret?: string): string {\n debug('check secret key');\n if (typeof secret === 'string' && _.isEmpty(secret) === false) {\n this.secret = secret;\n debug('reusing previous key');\n return secret;\n }\n // generate a new a secret key\n // FUTURE: this might be an external secret key, perhaps within config file?\n debug('generate a new key');\n //\n if (this.configOptions.forceEnhancedLegacySignature) {\n this.secret = generateRandomSecretKey();\n } else {\n this.secret =\n this.security.enhancedLegacySignature === true\n ? generateRandomSecretKey()\n : generateRandomHexString(32);\n // set this to false allow use old token signature and is not recommended\n // only use for migration reasons, major release will remove this property and\n // set it by default\n if (this.security.enhancedLegacySignature === false) {\n warningUtils.emit(Codes.VERWAR005);\n }\n }\n\n debug('generated a new secret key %s', this.secret?.length);\n return this.secret;\n }\n}\n\nexport { Config };\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAYA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,eAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,QAAA,GAAAX,OAAA;AAAuE,SAAAD,uBAAAa,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAA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D,MAAM,KAAK,QAAQ,IAAI9B,eAAC,CAACgC,OAAO,CAACF,MAAM,CAAC,KAAK,KAAK,EAAE;MAC7D,IAAI,CAACA,MAAM,GAAGA,MAAM;MACpB1D,KAAK,CAAC,sBAAsB,CAAC;MAC7B,OAAO0D,MAAM;IACf;IACA;IACA;IACA1D,KAAK,CAAC,oBAAoB,CAAC;IAC3B;IACA,IAAI,IAAI,CAACU,aAAa,CAACC,4BAA4B,EAAE;MACnD,IAAI,CAAC+C,MAAM,GAAG,IAAAG,8BAAuB,EAAC,CAAC;IACzC,CAAC,MAAM;MACL,IAAI,CAACH,MAAM,GACT,IAAI,CAAC/B,QAAQ,CAACmC,uBAAuB,KAAK,IAAI,GAC1C,IAAAD,8BAAuB,EAAC,CAAC,GACzB,IAAAR,8BAAuB,EAAC,EAAE,CAAC;MACjC;MACA;MACA;MACA,IAAI,IAAI,CAAC1B,QAAQ,CAACmC,uBAAuB,KAAK,KAAK,EAAE;QACnDC,kBAAY,CAACC,IAAI,CAACC,mBAAK,CAACC,SAAS,CAAC;MACpC;IACF;IAEAlE,KAAK,CAAC,+BAA+B,GAAA2D,YAAA,GAAE,IAAI,CAACD,MAAM,cAAAC,YAAA,uBAAXA,YAAA,CAAaQ,MAAM,CAAC;IAC3D,OAAO,IAAI,CAACT,MAAM;EACpB;AACF;AAACvD,OAAA,CAAAI,MAAA,GAAAA,MAAA"}
|
|
1
|
+
{"version":3,"file":"config.js","names":["_assert","_interopRequireDefault","require","_debug","_lodash","_core","_warningUtils","_utils","_agent","_packageAccess","_security","_serverSettings","_token","_uplinks","obj","__esModule","default","strategicConfigProps","allowedEnvConfig","debug","buildDebug","WEB_TITLE","exports","defaultUserRateLimiting","windowMs","max","Config","constructor","config","configOptions","forceEnhancedLegacySignature","_config$flags$searchR","_config$flags","_config$flags$changeP","_config$flags2","self","storage","process","env","VERDACCIO_STORAGE_PATH","configPath","_config$config_path","config_path","self_path","Error","plugins","security","_","merge","defaultSecurity","serverSettings","flags","searchRemote","changePassword","user_agent","configProp","getUserAgent","userRateLimit","assert","isObject","APP_ERROR","CONFIG_NOT_VALID","forEach","x","uplinks","sanityCheckUplinksProps","uplinkSanityCheck","packages","normalisePackageAccess","envConf","toUpperCase","server_id","generateRandomHexString","getEnhancedLegacySignature","enhancedLegacySignature","getConfigPath","getMatchedPackagesSpec","pkgName","checkSecretKey","secret","_this$security","_this$secret","isEmpty","generateRandomSecretKey","warningUtils","emit","Codes","VERWAR005","length"],"sources":["../src/config.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { APP_ERROR, warningUtils } from '@verdaccio/core';\nimport { Codes } from '@verdaccio/core/build/warning-utils';\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 public configPath: string;\n /**\n * @deprecated use configPath or config.getConfigPath();\n */\n public self_path: 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 private configOptions: { forceEnhancedLegacySignature: boolean };\n public constructor(\n config: ConfigYaml & { config_path: string },\n // forceEnhancedLegacySignature is a property that\n // allows switch a new legacy aes signature token signature\n // for older versions do not want to have this new signature model\n // this property must be false\n configOptions = { forceEnhancedLegacySignature: true }\n ) {\n const self = this;\n this.configOptions = configOptions;\n this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;\n if (!config.configPath) {\n // backport self_path for previous to version 6\n // @ts-expect-error\n config.configPath = config.config_path ?? config.self_path;\n if (!config.configPath) {\n throw new Error('configPath property is required');\n }\n }\n this.configPath = config.configPath;\n this.self_path = this.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 changePassword: config.flags?.changePassword ?? false,\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 public getEnhancedLegacySignature() {\n if (typeof this?.security.enhancedLegacySignature !== 'undefined') {\n if (this.security.enhancedLegacySignature === true) {\n return true;\n }\n return false;\n }\n return this.configOptions.forceEnhancedLegacySignature;\n }\n\n public getConfigPath() {\n return this.configPath;\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 * @secret external secret key\n */\n public checkSecretKey(secret?: string): string {\n debug('check secret key');\n if (typeof secret === 'string' && _.isEmpty(secret) === false) {\n this.secret = secret;\n debug('reusing previous key');\n return secret;\n }\n // generate a new a secret key\n // FUTURE: this might be an external secret key, perhaps within config file?\n debug('generating a new secret key');\n\n if (this.getEnhancedLegacySignature()) {\n debug('key generated with \"enhanced\" legacy signature user config');\n this.secret = generateRandomSecretKey();\n } else {\n debug('key generated with legacy signature user config');\n this.secret = generateRandomHexString(32);\n }\n // set this to false allow use old token signature and is not recommended\n // only use for migration reasons, major release will remove this property and\n // set it by default\n if (this.security?.enhancedLegacySignature === false) {\n warningUtils.emit(Codes.VERWAR005);\n }\n\n debug('generated a new secret key length %s', this.secret?.length);\n return this.secret;\n }\n}\n\nexport { Config };\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAYA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,eAAA,GAAAV,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,MAAM,CAAC;IAClE,OAAO,IAAI,CAACT,MAAM;EACpB;AACF;AAACzD,OAAA,CAAAI,MAAA,GAAAA,MAAA"}
|
package/build/package-access.js
CHANGED
|
@@ -11,7 +11,7 @@ var _lodash = _interopRequireDefault(require("lodash"));
|
|
|
11
11
|
var _core = require("@verdaccio/core");
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
// @deprecated use @verdaccio/core:authUtils
|
|
14
|
-
const ROLES = {
|
|
14
|
+
const ROLES = exports.ROLES = {
|
|
15
15
|
$ALL: '$all',
|
|
16
16
|
ALL: 'all',
|
|
17
17
|
$AUTH: '$authenticated',
|
|
@@ -22,12 +22,10 @@ const ROLES = {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
// @deprecated use @verdaccio/core:authUtils
|
|
25
|
-
exports.
|
|
26
|
-
const PACKAGE_ACCESS = {
|
|
25
|
+
const PACKAGE_ACCESS = exports.PACKAGE_ACCESS = {
|
|
27
26
|
SCOPE: '@*/*',
|
|
28
27
|
ALL: '**'
|
|
29
28
|
};
|
|
30
|
-
exports.PACKAGE_ACCESS = PACKAGE_ACCESS;
|
|
31
29
|
function normalizeUserList(groupsList) {
|
|
32
30
|
const result = [];
|
|
33
31
|
if (_lodash.default.isNil(groupsList)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-access.js","names":["_assert","_interopRequireDefault","require","_lodash","_core","obj","__esModule","default","ROLES","$ALL","ALL","$AUTH","$ANONYMOUS","DEPRECATED_ALL","DEPRECATED_AUTH","DEPRECATED_ANONYMOUS","
|
|
1
|
+
{"version":3,"file":"package-access.js","names":["_assert","_interopRequireDefault","require","_lodash","_core","obj","__esModule","default","ROLES","exports","$ALL","ALL","$AUTH","$ANONYMOUS","DEPRECATED_ALL","DEPRECATED_AUTH","DEPRECATED_ANONYMOUS","PACKAGE_ACCESS","SCOPE","normalizeUserList","groupsList","result","_","isNil","isString","groupsArray","split","push","Array","isArray","errorUtils","getInternalError","JSON","stringify","flatten","normalisePackageAccess","packages","normalizedPkgs","access","publish","unpublish","proxy","pkg","Object","prototype","hasOwnProperty","call","packageAccess","isInvalid","isObject","assert","isUndefined"],"sources":["../src/package-access.ts"],"sourcesContent":["import assert from 'assert';\nimport _ from 'lodash';\n\nimport { errorUtils } from '@verdaccio/core';\nimport { PackageAccess } from '@verdaccio/types';\n\nexport interface LegacyPackageList {\n [key: string]: PackageAccess;\n}\n\n// @deprecated use @verdaccio/core:authUtils\nexport const ROLES = {\n $ALL: '$all',\n ALL: 'all',\n $AUTH: '$authenticated',\n $ANONYMOUS: '$anonymous',\n DEPRECATED_ALL: '@all',\n DEPRECATED_AUTH: '@authenticated',\n DEPRECATED_ANONYMOUS: '@anonymous',\n};\n\n// @deprecated use @verdaccio/core:authUtils\nexport const PACKAGE_ACCESS = {\n SCOPE: '@*/*',\n ALL: '**',\n};\n\nexport function normalizeUserList(groupsList: any): any {\n const result: any[] = [];\n if (_.isNil(groupsList)) {\n return result;\n }\n\n // if it's a string, split it to array\n if (_.isString(groupsList)) {\n const groupsArray = groupsList.split(/\\s+/);\n\n result.push(groupsArray);\n } else if (Array.isArray(groupsList)) {\n result.push(groupsList);\n } else {\n throw errorUtils.getInternalError(\n 'CONFIG: bad package acl (array or string expected): ' + JSON.stringify(groupsList)\n );\n }\n\n return _.flatten(result);\n}\n\nexport function normalisePackageAccess(packages: LegacyPackageList): LegacyPackageList {\n const normalizedPkgs: LegacyPackageList = { ...packages };\n if (_.isNil(normalizedPkgs['**'])) {\n normalizedPkgs['**'] = {\n access: [],\n publish: [],\n unpublish: [],\n proxy: [],\n };\n }\n\n for (const pkg in packages) {\n if (Object.prototype.hasOwnProperty.call(packages, pkg)) {\n const packageAccess = packages[pkg];\n const isInvalid = _.isObject(packageAccess) && _.isArray(packageAccess) === false;\n assert(isInvalid, `CONFIG: bad \"'${pkg}'\" package description (object expected)`);\n\n normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);\n normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);\n normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);\n // if unpublish is not defined, we set to false to fallback in publish access\n normalizedPkgs[pkg].unpublish = _.isUndefined(packageAccess.unpublish)\n ? false\n : normalizeUserList(packageAccess.unpublish);\n }\n }\n\n return normalizedPkgs;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAA6C,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAO7C;AACO,MAAMG,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAG;EACnBE,IAAI,EAAE,MAAM;EACZC,GAAG,EAAE,KAAK;EACVC,KAAK,EAAE,gBAAgB;EACvBC,UAAU,EAAE,YAAY;EACxBC,cAAc,EAAE,MAAM;EACtBC,eAAe,EAAE,gBAAgB;EACjCC,oBAAoB,EAAE;AACxB,CAAC;;AAED;AACO,MAAMC,cAAc,GAAAR,OAAA,CAAAQ,cAAA,GAAG;EAC5BC,KAAK,EAAE,MAAM;EACbP,GAAG,EAAE;AACP,CAAC;AAEM,SAASQ,iBAAiBA,CAACC,UAAe,EAAO;EACtD,MAAMC,MAAa,GAAG,EAAE;EACxB,IAAIC,eAAC,CAACC,KAAK,CAACH,UAAU,CAAC,EAAE;IACvB,OAAOC,MAAM;EACf;;EAEA;EACA,IAAIC,eAAC,CAACE,QAAQ,CAACJ,UAAU,CAAC,EAAE;IAC1B,MAAMK,WAAW,GAAGL,UAAU,CAACM,KAAK,CAAC,KAAK,CAAC;IAE3CL,MAAM,CAACM,IAAI,CAACF,WAAW,CAAC;EAC1B,CAAC,MAAM,IAAIG,KAAK,CAACC,OAAO,CAACT,UAAU,CA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AAG,CAAC,CAACF,SAAS,GAAGlB,eAAC,CAAC6B,WAAW,CAACJ,aAAa,CAACP,SAAS,CAAC,GAClE,KAAK,GACLrB,iBAAiB,CAAC4B,aAAa,CAACP,SAAS,CAAC;IAChD;EACF;EAEA,OAAOH,cAAc;AACvB"}
|
package/build/security.js
CHANGED
|
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.defaultSecurity = exports.TIME_EXPIRATION_1H = void 0;
|
|
7
7
|
// TODO: get this from core package
|
|
8
|
-
const TIME_EXPIRATION_1H = '1h';
|
|
9
|
-
exports.TIME_EXPIRATION_1H = TIME_EXPIRATION_1H;
|
|
8
|
+
const TIME_EXPIRATION_1H = exports.TIME_EXPIRATION_1H = '1h';
|
|
10
9
|
const defaultWebTokenOptions = {
|
|
11
10
|
sign: {
|
|
12
11
|
// The expiration token for the website is 7 days
|
|
@@ -17,9 +16,8 @@ const defaultWebTokenOptions = {
|
|
|
17
16
|
const defaultApiTokenConf = {
|
|
18
17
|
legacy: true
|
|
19
18
|
};
|
|
20
|
-
const defaultSecurity = {
|
|
19
|
+
const defaultSecurity = exports.defaultSecurity = {
|
|
21
20
|
web: defaultWebTokenOptions,
|
|
22
21
|
api: defaultApiTokenConf
|
|
23
22
|
};
|
|
24
|
-
exports.defaultSecurity = defaultSecurity;
|
|
25
23
|
//# sourceMappingURL=security.js.map
|
package/build/security.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.js","names":["TIME_EXPIRATION_1H","exports","defaultWebTokenOptions","sign","expiresIn","verify","defaultApiTokenConf","legacy","defaultSecurity","web","api"],"sources":["../src/security.ts"],"sourcesContent":["import { APITokenOptions, JWTOptions, Security } from '@verdaccio/types';\n\n// TODO: get this from core package\nexport const TIME_EXPIRATION_1H = '1h';\n\nconst defaultWebTokenOptions: JWTOptions = {\n sign: {\n // The expiration token for the website is 7 days\n expiresIn: TIME_EXPIRATION_1H,\n },\n verify: {},\n};\n\nconst defaultApiTokenConf: APITokenOptions = {\n legacy: true,\n};\n\nexport const defaultSecurity: Security = {\n web: defaultWebTokenOptions,\n api: defaultApiTokenConf,\n};\n"],"mappings":";;;;;;AAEA;AACO,MAAMA,kBAAkB,
|
|
1
|
+
{"version":3,"file":"security.js","names":["TIME_EXPIRATION_1H","exports","defaultWebTokenOptions","sign","expiresIn","verify","defaultApiTokenConf","legacy","defaultSecurity","web","api"],"sources":["../src/security.ts"],"sourcesContent":["import { APITokenOptions, JWTOptions, Security } from '@verdaccio/types';\n\n// TODO: get this from core package\nexport const TIME_EXPIRATION_1H = '1h';\n\nconst defaultWebTokenOptions: JWTOptions = {\n sign: {\n // The expiration token for the website is 7 days\n expiresIn: TIME_EXPIRATION_1H,\n },\n verify: {},\n};\n\nconst defaultApiTokenConf: APITokenOptions = {\n legacy: true,\n};\n\nexport const defaultSecurity: Security = {\n web: defaultWebTokenOptions,\n api: defaultApiTokenConf,\n};\n"],"mappings":";;;;;;AAEA;AACO,MAAMA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,IAAI;AAEtC,MAAME,sBAAkC,GAAG;EACzCC,IAAI,EAAE;IACJ;IACAC,SAAS,EAAEJ;EACb,CAAC;EACDK,MAAM,EAAE,CAAC;AACX,CAAC;AAED,MAAMC,mBAAoC,GAAG;EAC3CC,MAAM,EAAE;AACV,CAAC;AAEM,MAAMC,eAAyB,GAAAP,OAAA,CAAAO,eAAA,GAAG;EACvCC,GAAG,EAAEP,sBAAsB;EAC3BQ,GAAG,EAAEJ;AACP,CAAC"}
|
package/build/serverSettings.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _default = {
|
|
7
|
+
var _default = exports.default = {
|
|
8
8
|
// https://www.npmjs.com/package/express-rate-limit
|
|
9
9
|
// values are intended to be high, please customize based on own needs
|
|
10
10
|
rateLimit: {
|
|
@@ -14,5 +14,4 @@ var _default = {
|
|
|
14
14
|
// deprecated
|
|
15
15
|
keepAliveTimeout: 60
|
|
16
16
|
};
|
|
17
|
-
exports.default = _default;
|
|
18
17
|
//# sourceMappingURL=serverSettings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverSettings.js","names":["rateLimit","windowMs","max","keepAliveTimeout"
|
|
1
|
+
{"version":3,"file":"serverSettings.js","names":["rateLimit","windowMs","max","keepAliveTimeout"],"sources":["../src/serverSettings.ts"],"sourcesContent":["export default {\n // https://www.npmjs.com/package/express-rate-limit\n // values are intended to be high, please customize based on own needs\n rateLimit: {\n windowMs: 1000,\n max: 10000,\n },\n // deprecated\n keepAliveTimeout: 60,\n};\n"],"mappings":";;;;;;iCAAe;EACb;EACA;EACAA,SAAS,EAAE;IACTC,QAAQ,EAAE,IAAI;IACdC,GAAG,EAAE;EACP,CAAC;EACD;EACAC,gBAAgB,EAAE;AACpB,CAAC"}
|
package/build/token.js
CHANGED
|
@@ -6,12 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.TOKEN_VALID_LENGTH = void 0;
|
|
7
7
|
exports.generateRandomSecretKey = generateRandomSecretKey;
|
|
8
8
|
var _crypto = require("crypto");
|
|
9
|
-
const TOKEN_VALID_LENGTH = 32;
|
|
9
|
+
const TOKEN_VALID_LENGTH = exports.TOKEN_VALID_LENGTH = 32;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Secret key must have 32 characters.
|
|
13
13
|
*/
|
|
14
|
-
exports.TOKEN_VALID_LENGTH = TOKEN_VALID_LENGTH;
|
|
15
14
|
function generateRandomSecretKey() {
|
|
16
15
|
return (0, _crypto.randomBytes)(TOKEN_VALID_LENGTH).toString('base64').substring(0, TOKEN_VALID_LENGTH);
|
|
17
16
|
}
|
package/build/token.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","names":["_crypto","require","TOKEN_VALID_LENGTH","exports","generateRandomSecretKey","randomBytes","toString","substring"],"sources":["../src/token.ts"],"sourcesContent":["import { randomBytes } from 'crypto';\n\nexport const TOKEN_VALID_LENGTH = 32;\n\n/**\n * Secret key must have 32 characters.\n */\nexport function generateRandomSecretKey(): string {\n return randomBytes(TOKEN_VALID_LENGTH).toString('base64').substring(0, TOKEN_VALID_LENGTH);\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEO,MAAMC,kBAAkB,GAAG,EAAE;;AAEpC;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"token.js","names":["_crypto","require","TOKEN_VALID_LENGTH","exports","generateRandomSecretKey","randomBytes","toString","substring"],"sources":["../src/token.ts"],"sourcesContent":["import { randomBytes } from 'crypto';\n\nexport const TOKEN_VALID_LENGTH = 32;\n\n/**\n * Secret key must have 32 characters.\n */\nexport function generateRandomSecretKey(): string {\n return randomBytes(TOKEN_VALID_LENGTH).toString('base64').substring(0, TOKEN_VALID_LENGTH);\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEO,MAAMC,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,EAAE;;AAEpC;AACA;AACA;AACO,SAASE,uBAAuBA,CAAA,EAAW;EAChD,OAAO,IAAAC,mBAAW,EAACH,kBAAkB,CAAC,CAACI,QAAQ,CAAC,QAAQ,CAAC,CAACC,SAAS,CAAC,CAAC,EAAEL,kBAAkB,CAAC;AAC5F"}
|
package/build/uplinks.js
CHANGED
|
@@ -12,10 +12,8 @@ var _assert = _interopRequireDefault(require("assert"));
|
|
|
12
12
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
13
|
var _utils = require("@verdaccio/utils");
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
|
16
|
-
exports.
|
|
17
|
-
const DEFAULT_UPLINK = 'npmjs';
|
|
18
|
-
exports.DEFAULT_UPLINK = DEFAULT_UPLINK;
|
|
15
|
+
const DEFAULT_REGISTRY = exports.DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
|
16
|
+
const DEFAULT_UPLINK = exports.DEFAULT_UPLINK = 'npmjs';
|
|
19
17
|
const BLACKLIST = {
|
|
20
18
|
all: true,
|
|
21
19
|
anonymous: true,
|
package/build/uplinks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uplinks.js","names":["_assert","_interopRequireDefault","require","_lodash","_utils","obj","__esModule","default","DEFAULT_REGISTRY","exports","DEFAULT_UPLINK","BLACKLIST","all","anonymous","undefined","owner","none","uplinkSanityCheck","uplinks","users","newUplinks","_","clone","newUsers","uplink","Object","prototype","hasOwnProperty","call","cache","sanityCheckNames","sanityCheckUplinksProps","configUpLinks","assert","url","isString","replace","hasProxyTo","pkg","upLink","packages","matchedPkg","getMatchedPackagesSpec","proxyList","proxy","some","curr","item","match","isNil"],"sources":["../src/uplinks.ts"],"sourcesContent":["import assert from 'assert';\nimport _ from 'lodash';\n\nimport { PackageList, UpLinksConfList } from '@verdaccio/types';\nimport { getMatchedPackagesSpec } from '@verdaccio/utils';\n\nexport const DEFAULT_REGISTRY = 'https://registry.npmjs.org';\nexport const DEFAULT_UPLINK = 'npmjs';\n\nconst BLACKLIST = {\n all: true,\n anonymous: true,\n undefined: true,\n owner: true,\n none: true,\n};\n\nexport function uplinkSanityCheck(\n uplinks: UpLinksConfList,\n users: any = BLACKLIST\n): UpLinksConfList {\n const newUplinks = _.clone(uplinks);\n let newUsers = _.clone(users);\n\n for (const uplink in newUplinks) {\n if (Object.prototype.hasOwnProperty.call(newUplinks, uplink)) {\n if (typeof newUplinks[uplink].cache === 'undefined') {\n newUplinks[uplink].cache = true;\n }\n newUsers = sanityCheckNames(uplink, newUsers);\n }\n }\n\n return newUplinks;\n}\n\nexport function sanityCheckUplinksProps(configUpLinks: UpLinksConfList): UpLinksConfList {\n const uplinks = _.clone(configUpLinks);\n\n for (const uplink in uplinks) {\n if (Object.prototype.hasOwnProperty.call(uplinks, uplink)) {\n assert(uplinks[uplink].url, 'CONFIG: no url for uplink: ' + uplink);\n assert(_.isString(uplinks[uplink].url), 'CONFIG: wrong url format for uplink: ' + uplink);\n uplinks[uplink].url = uplinks[uplink].url.replace(/\\/$/, '');\n }\n }\n\n return uplinks;\n}\n\nexport function hasProxyTo(pkg: string, upLink: string, packages: PackageList): boolean {\n const matchedPkg = getMatchedPackagesSpec(pkg, packages);\n const proxyList = typeof matchedPkg !== 'undefined' ? matchedPkg.proxy : [];\n if (proxyList) {\n return proxyList.some((curr) => upLink === curr);\n }\n\n return false;\n}\n\nexport function sanityCheckNames(item: string, users: any): any {\n assert(\n item !== 'all' &&\n item !== 'owner' &&\n item !== 'anonymous' &&\n item !== 'undefined' &&\n item !== 'none',\n 'CONFIG: reserved uplink name: ' + item\n );\n assert(!item.match(/\\s/), 'CONFIG: invalid uplink name: ' + item);\n assert(_.isNil(users[item]), 'CONFIG: duplicate uplink name: ' + item);\n users[item] = true;\n\n return users;\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA,IAAAE,MAAA,GAAAF,OAAA;AAA0D,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEnD,MAAMG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"uplinks.js","names":["_assert","_interopRequireDefault","require","_lodash","_utils","obj","__esModule","default","DEFAULT_REGISTRY","exports","DEFAULT_UPLINK","BLACKLIST","all","anonymous","undefined","owner","none","uplinkSanityCheck","uplinks","users","newUplinks","_","clone","newUsers","uplink","Object","prototype","hasOwnProperty","call","cache","sanityCheckNames","sanityCheckUplinksProps","configUpLinks","assert","url","isString","replace","hasProxyTo","pkg","upLink","packages","matchedPkg","getMatchedPackagesSpec","proxyList","proxy","some","curr","item","match","isNil"],"sources":["../src/uplinks.ts"],"sourcesContent":["import assert from 'assert';\nimport _ from 'lodash';\n\nimport { PackageList, UpLinksConfList } from '@verdaccio/types';\nimport { getMatchedPackagesSpec } from '@verdaccio/utils';\n\nexport const DEFAULT_REGISTRY = 'https://registry.npmjs.org';\nexport const DEFAULT_UPLINK = 'npmjs';\n\nconst BLACKLIST = {\n all: true,\n anonymous: true,\n undefined: true,\n owner: true,\n none: true,\n};\n\nexport function uplinkSanityCheck(\n uplinks: UpLinksConfList,\n users: any = BLACKLIST\n): UpLinksConfList {\n const newUplinks = _.clone(uplinks);\n let newUsers = _.clone(users);\n\n for (const uplink in newUplinks) {\n if (Object.prototype.hasOwnProperty.call(newUplinks, uplink)) {\n if (typeof newUplinks[uplink].cache === 'undefined') {\n newUplinks[uplink].cache = true;\n }\n newUsers = sanityCheckNames(uplink, newUsers);\n }\n }\n\n return newUplinks;\n}\n\nexport function sanityCheckUplinksProps(configUpLinks: UpLinksConfList): UpLinksConfList {\n const uplinks = _.clone(configUpLinks);\n\n for (const uplink in uplinks) {\n if (Object.prototype.hasOwnProperty.call(uplinks, uplink)) {\n assert(uplinks[uplink].url, 'CONFIG: no url for uplink: ' + uplink);\n assert(_.isString(uplinks[uplink].url), 'CONFIG: wrong url format for uplink: ' + uplink);\n uplinks[uplink].url = uplinks[uplink].url.replace(/\\/$/, '');\n }\n }\n\n return uplinks;\n}\n\nexport function hasProxyTo(pkg: string, upLink: string, packages: PackageList): boolean {\n const matchedPkg = getMatchedPackagesSpec(pkg, packages);\n const proxyList = typeof matchedPkg !== 'undefined' ? matchedPkg.proxy : [];\n if (proxyList) {\n return proxyList.some((curr) => upLink === curr);\n }\n\n return false;\n}\n\nexport function sanityCheckNames(item: string, users: any): any {\n assert(\n item !== 'all' &&\n item !== 'owner' &&\n item !== 'anonymous' &&\n item !== 'undefined' &&\n item !== 'none',\n 'CONFIG: reserved uplink name: ' + item\n );\n assert(!item.match(/\\s/), 'CONFIG: invalid uplink name: ' + item);\n assert(_.isNil(users[item]), 'CONFIG: duplicate uplink name: ' + item);\n users[item] = true;\n\n return users;\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA,IAAAE,MAAA,GAAAF,OAAA;AAA0D,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEnD,MAAMG,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,4BAA4B;AACrD,MAAME,cAAc,GAAAD,OAAA,CAAAC,cAAA,GAAG,OAAO;AAErC,MAAMC,SAAS,GAAG;EAChBC,GAAG,EAAE,IAAI;EACTC,SAAS,EAAE,IAAI;EACfC,SAAS,EAAE,IAAI;EACfC,KAAK,EAAE,IAAI;EACXC,IAAI,EAAE;AACR,CAAC;AAEM,SAASC,iBAAiBA,CAC/BC,OAAwB,EACxBC,KAAU,GAAGR,SAAS,EACL;EACjB,MAAMS,UAAU,GAAGC,eAAC,CAACC,KAAK,CAACJ,OAAO,CAAC;EACnC,IAAIK,QAAQ,GAAGF,eAAC,CAACC,KAAK,CAACH,KAAK,CAAC;EAE7B,KAAK,MAAMK,MAAM,IAAIJ,UAAU,EAAE;IAC/B,IAAIK,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACR,UAAU,EAAEI,MAAM,CAAC,EAAE;MAC5D,IAAI,OAAOJ,UAAU,CAACI,MAAM,CAAC,CAACK,KAAK,KAAK,WAAW,EAAE;QACnDT,UAAU,CAACI,MAAM,CAAC,CAACK,KAAK,GAAG,IAAI;MACjC;MACAN,QAAQ,GAAGO,gBAAgB,CAACN,MAAM,EAAED,QAAQ,CAAC;IAC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jB,gCAAgC,GAAGA,IACrC,CAAC;EACD,IAAAd,eAAM,EAAC,CAACc,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE,+BAA+B,GAAGD,IAAI,CAAC;EACjE,IAAAd,eAAM,EAACZ,eAAC,CAAC4B,KAAK,CAAC9B,KAAK,CAAC4B,IAAI,CAAC,CAAC,EAAE,iCAAiC,GAAGA,IAAI,CAAC;EACtE5B,KAAK,CAAC4B,IAAI,CAAC,GAAG,IAAI;EAElB,OAAO5B,KAAK;AACd"}
|
package/build/user.js
CHANGED
|
@@ -10,12 +10,11 @@ var _packageAccess = require("./package-access");
|
|
|
10
10
|
/**
|
|
11
11
|
* All logged users will have by default the group $all and $authenticate
|
|
12
12
|
*/
|
|
13
|
-
const defaultLoggedUserRoles = [_packageAccess.ROLES.$ALL, _packageAccess.ROLES.$AUTH, _packageAccess.ROLES.DEPRECATED_ALL, _packageAccess.ROLES.DEPRECATED_AUTH, _packageAccess.ROLES.ALL];
|
|
13
|
+
const defaultLoggedUserRoles = exports.defaultLoggedUserRoles = [_packageAccess.ROLES.$ALL, _packageAccess.ROLES.$AUTH, _packageAccess.ROLES.DEPRECATED_ALL, _packageAccess.ROLES.DEPRECATED_AUTH, _packageAccess.ROLES.ALL];
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
|
-
exports.
|
|
18
|
-
const defaultNonLoggedUserRoles = [_packageAccess.ROLES.$ALL, _packageAccess.ROLES.$ANONYMOUS,
|
|
17
|
+
const defaultNonLoggedUserRoles = exports.defaultNonLoggedUserRoles = [_packageAccess.ROLES.$ALL, _packageAccess.ROLES.$ANONYMOUS,
|
|
19
18
|
// groups without '$' are going to be deprecated eventually
|
|
20
19
|
_packageAccess.ROLES.DEPRECATED_ALL, _packageAccess.ROLES.DEPRECATED_ANONYMOUS];
|
|
21
20
|
|
|
@@ -23,7 +22,6 @@ _packageAccess.ROLES.DEPRECATED_ALL, _packageAccess.ROLES.DEPRECATED_ANONYMOUS];
|
|
|
23
22
|
* Create a RemoteUser object
|
|
24
23
|
* @return {Object} { name: xx, pluginGroups: [], real_groups: [] }
|
|
25
24
|
*/
|
|
26
|
-
exports.defaultNonLoggedUserRoles = defaultNonLoggedUserRoles;
|
|
27
25
|
function createRemoteUser(name, pluginGroups) {
|
|
28
26
|
const isGroupValid = Array.isArray(pluginGroups);
|
|
29
27
|
const groups = Array.from(new Set((isGroupValid ? pluginGroups : []).concat([...defaultLoggedUserRoles])));
|
package/build/user.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","names":["_packageAccess","require","defaultLoggedUserRoles","ROLES","$ALL","$AUTH","DEPRECATED_ALL","DEPRECATED_AUTH","ALL","
|
|
1
|
+
{"version":3,"file":"user.js","names":["_packageAccess","require","defaultLoggedUserRoles","exports","ROLES","$ALL","$AUTH","DEPRECATED_ALL","DEPRECATED_AUTH","ALL","defaultNonLoggedUserRoles","$ANONYMOUS","DEPRECATED_ANONYMOUS","createRemoteUser","name","pluginGroups","isGroupValid","Array","isArray","groups","from","Set","concat","real_groups","createAnonymousRemoteUser","undefined"],"sources":["../src/user.ts"],"sourcesContent":["import { RemoteUser } from '@verdaccio/types';\n\nimport { ROLES } from './package-access';\n\n/**\n * All logged users will have by default the group $all and $authenticate\n */\nexport const defaultLoggedUserRoles = [\n ROLES.$ALL,\n ROLES.$AUTH,\n ROLES.DEPRECATED_ALL,\n ROLES.DEPRECATED_AUTH,\n ROLES.ALL,\n];\n/**\n *\n */\nexport const defaultNonLoggedUserRoles = [\n ROLES.$ALL,\n ROLES.$ANONYMOUS,\n // groups without '$' are going to be deprecated eventually\n ROLES.DEPRECATED_ALL,\n ROLES.DEPRECATED_ANONYMOUS,\n];\n\n/**\n * Create a RemoteUser object\n * @return {Object} { name: xx, pluginGroups: [], real_groups: [] }\n */\nexport function createRemoteUser(name: string, pluginGroups: string[]): RemoteUser {\n const isGroupValid: boolean = Array.isArray(pluginGroups);\n const groups = Array.from(\n new Set((isGroupValid ? pluginGroups : []).concat([...defaultLoggedUserRoles]))\n );\n\n return {\n name,\n groups,\n real_groups: pluginGroups,\n };\n}\n\n/**\n * Builds an anonymous remote user in case none is logged in.\n * @return {Object} { name: xx, groups: [], real_groups: [] }\n */\nexport function createAnonymousRemoteUser(): RemoteUser {\n return {\n name: undefined,\n groups: [...defaultNonLoggedUserRoles],\n real_groups: [],\n };\n}\n"],"mappings":";;;;;;;;AAEA,IAAAA,cAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACO,MAAMC,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,CACpCE,oBAAK,CAACC,IAAI,EACVD,oBAAK,CAACE,KAAK,EACXF,oBAAK,CAACG,cAAc,EACpBH,oBAAK,CAACI,eAAe,EACrBJ,oBAAK,CAACK,GAAG,CACV;AACD;AACA;AACA;AACO,MAAMC,yBAAyB,GAAAP,OAAA,CAAAO,yBAAA,GAAG,CACvCN,oBAAK,CAACC,IAAI,EACVD,oBAAK,CAACO,UAAU;AAChB;AACAP,oBAAK,CAACG,cAAc,EACpBH,oBAAK,CAACQ,oBAAoB,CAC3B;;AAED;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAACC,IAAY,EAAEC,YAAsB,EAAc;EACjF,MAAMC,YAAqB,GAAGC,KAAK,CAACC,OAAO,CAACH,YAAY,CAAC;EACzD,MAAMI,MAAM,GAAGF,KAAK,CAACG,IAAI,CACvB,IAAIC,GAAG,CAAC,CAACL,YAAY,GAAGD,YAAY,GAAG,EAAE,EAAEO,MAAM,CAAC,CAAC,GAAGpB,sBAAsB,CAAC,CAAC,CAChF,CAAC;EAED,OAAO;IACLY,IAAI;IACJK,MAAM;IACNI,WAAW,EAAER;EACf,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACO,SAASS,yBAAyBA,CAAA,EAAe;EACtD,OAAO;IACLV,IAAI,EAAEW,SAAS;IACfN,MAAM,EAAE,CAAC,GAAGT,yBAAyB,CAAC;IACtCa,WAAW,EAAE;EACf,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/config",
|
|
3
|
-
"version": "7.0.0-next.
|
|
3
|
+
"version": "7.0.0-next.5",
|
|
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": "7.0.0-next.
|
|
33
|
-
"@verdaccio/utils": "7.0.0-next.
|
|
32
|
+
"@verdaccio/core": "7.0.0-next.5",
|
|
33
|
+
"@verdaccio/utils": "7.0.0-next.5",
|
|
34
34
|
"debug": "4.3.4",
|
|
35
35
|
"js-yaml": "4.1.0",
|
|
36
36
|
"lodash": "4.17.21",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/minimatch": "5.1.2",
|
|
42
|
-
"@types/yup": "0.
|
|
42
|
+
"@types/yup": "0.32.0"
|
|
43
43
|
},
|
|
44
44
|
"funding": {
|
|
45
45
|
"type": "opencollective",
|
package/src/config.ts
CHANGED
|
@@ -63,6 +63,10 @@ class Config implements AppConfig {
|
|
|
63
63
|
private configOptions: { forceEnhancedLegacySignature: boolean };
|
|
64
64
|
public constructor(
|
|
65
65
|
config: ConfigYaml & { config_path: string },
|
|
66
|
+
// forceEnhancedLegacySignature is a property that
|
|
67
|
+
// allows switch a new legacy aes signature token signature
|
|
68
|
+
// for older versions do not want to have this new signature model
|
|
69
|
+
// this property must be false
|
|
66
70
|
configOptions = { forceEnhancedLegacySignature: true }
|
|
67
71
|
) {
|
|
68
72
|
const self = this;
|
|
@@ -131,6 +135,16 @@ class Config implements AppConfig {
|
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
137
|
|
|
138
|
+
public getEnhancedLegacySignature() {
|
|
139
|
+
if (typeof this?.security.enhancedLegacySignature !== 'undefined') {
|
|
140
|
+
if (this.security.enhancedLegacySignature === true) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
return this.configOptions.forceEnhancedLegacySignature;
|
|
146
|
+
}
|
|
147
|
+
|
|
134
148
|
public getConfigPath() {
|
|
135
149
|
return this.configPath;
|
|
136
150
|
}
|
|
@@ -156,24 +170,23 @@ class Config implements AppConfig {
|
|
|
156
170
|
}
|
|
157
171
|
// generate a new a secret key
|
|
158
172
|
// FUTURE: this might be an external secret key, perhaps within config file?
|
|
159
|
-
debug('
|
|
160
|
-
|
|
161
|
-
if (this.
|
|
173
|
+
debug('generating a new secret key');
|
|
174
|
+
|
|
175
|
+
if (this.getEnhancedLegacySignature()) {
|
|
176
|
+
debug('key generated with "enhanced" legacy signature user config');
|
|
162
177
|
this.secret = generateRandomSecretKey();
|
|
163
178
|
} else {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
warningUtils.emit(Codes.VERWAR005);
|
|
173
|
-
}
|
|
179
|
+
debug('key generated with legacy signature user config');
|
|
180
|
+
this.secret = generateRandomHexString(32);
|
|
181
|
+
}
|
|
182
|
+
// set this to false allow use old token signature and is not recommended
|
|
183
|
+
// only use for migration reasons, major release will remove this property and
|
|
184
|
+
// set it by default
|
|
185
|
+
if (this.security?.enhancedLegacySignature === false) {
|
|
186
|
+
warningUtils.emit(Codes.VERWAR005);
|
|
174
187
|
}
|
|
175
188
|
|
|
176
|
-
debug('generated a new secret key %s', this.secret?.length);
|
|
189
|
+
debug('generated a new secret key length %s', this.secret?.length);
|
|
177
190
|
return this.secret;
|
|
178
191
|
}
|
|
179
192
|
}
|