@verdaccio/config 8.0.0-next-8.0 → 8.0.0-next-8.2
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/.babelrc +1 -1
- package/CHANGELOG.md +19 -0
- package/build/config-path.js +2 -2
- package/build/config-path.js.map +1 -1
- package/build/config.js +5 -8
- package/build/config.js.map +1 -1
- package/package.json +4 -4
package/.babelrc
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @verdaccio/config
|
|
2
2
|
|
|
3
|
+
## 8.0.0-next-8.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6a8154c: feat: update logger pino to latest
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [6a8154c]
|
|
12
|
+
- @verdaccio/core@8.0.0-next-8.2
|
|
13
|
+
- @verdaccio/utils@7.1.0-next-8.2
|
|
14
|
+
|
|
15
|
+
## 8.0.0-next-8.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- @verdaccio/core@8.0.0-next-8.1
|
|
20
|
+
- @verdaccio/utils@7.0.1-next-8.1
|
|
21
|
+
|
|
3
22
|
## 8.0.0-next-8.0
|
|
4
23
|
|
|
5
24
|
### Major Changes
|
package/build/config-path.js
CHANGED
|
@@ -42,7 +42,7 @@ function findConfigFile(configPath) {
|
|
|
42
42
|
// find the first location that already exist
|
|
43
43
|
const primaryConf = _lodash.default.find(configPaths, configLocation => (0, _configUtils.fileExists)(configLocation.path));
|
|
44
44
|
if (typeof primaryConf !== 'undefined') {
|
|
45
|
-
debug('at least one primary location detected at %s', primaryConf
|
|
45
|
+
debug('at least one primary location detected at %s', primaryConf?.path);
|
|
46
46
|
return primaryConf.path;
|
|
47
47
|
}
|
|
48
48
|
debug('no previous location found, creating a new one');
|
|
@@ -111,7 +111,7 @@ function getConfigPaths() {
|
|
|
111
111
|
const listPaths = [getXDGDirectory(), getWindowsDirectory(), getRelativeDefaultDirectory(), getOldDirectory()];
|
|
112
112
|
return listPaths.reduce(function (acc, currentValue) {
|
|
113
113
|
if (typeof currentValue !== 'undefined') {
|
|
114
|
-
debug('posible directory path generated %s for type %s', currentValue
|
|
114
|
+
debug('posible directory path generated %s for type %s', currentValue?.path, currentValue.type);
|
|
115
115
|
acc.push(currentValue);
|
|
116
116
|
}
|
|
117
117
|
return acc;
|
package/build/config-path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-path.js","names":["_debug","_interopRequireDefault","require","_fs","_lodash","_os","_path","_configUtils","e","__esModule","default","CONFIG_FILE","XDG","pkgJSON","name","debug","buildDebug","findConfigFile","configPath","configLocation","path","resolve","configPaths","getConfigPaths","length","Error","primaryConf","_","find","fileExists","createConfigFile","createConfigFolder","defaultConfig","updateStorageLinks","readDefaultConfig","fs","writeFileSync","pathDefaultConf","__dirname","accessSync","constants","R_OK","TypeError","readFileSync","folder","dirname","mkdirSync","recursive","type","dataDir","process","env","XDG_DATA_HOME","join","HOME","folderExists","replace","listPaths","getXDGDirectory","getWindowsDirectory","getRelativeDefaultDirectory","getOldDirectory","reduce","acc","currentValue","push","xDGConfigPath","XDG_CONFIG_HOME","os","platform","APPDATA","relativePath","oldPath"],"sources":["../src/config-path.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport fs from 'fs';\nimport _ from 'lodash';\nimport os from 'os';\nimport path from 'path';\n\nimport { fileExists, folderExists } from './config-utils';\n\nconst CONFIG_FILE = 'config.yaml';\nconst XDG = 'xdg';\n// eslint-disable-next-line\nconst pkgJSON = {\n name: 'verdaccio',\n};\n\nexport type SetupDirectory = {\n path: string;\n type: 'xdg' | 'win' | 'win32' | 'def' | 'old';\n};\n\nconst debug = buildDebug('verdaccio:config:config-path');\n\n/**\n * Find and get the first config file that match.\n * @return {String} the config file path\n */\nfunction findConfigFile(configPath?: string): string {\n debug('searching for config file %o', configPath);\n if (typeof configPath !== 'undefined') {\n const configLocation = path.resolve(configPath);\n debug('custom location %s', configLocation);\n return configLocation;\n }\n\n const configPaths: SetupDirectory[] = getConfigPaths();\n debug('%o posible locations found', configPaths.length);\n if (configPaths.length === 0) {\n debug('no configuration files can be processed');\n // this should never happens\n throw new Error('no configuration files can be processed');\n }\n\n // find the first location that already exist\n const primaryConf: SetupDirectory | void = _.find(configPaths, (configLocation: SetupDirectory) =>\n fileExists(configLocation.path)\n );\n\n if (typeof primaryConf !== 'undefined') {\n debug('at least one primary location detected at %s', primaryConf?.path);\n return primaryConf.path;\n }\n debug('no previous location found, creating a new one');\n debug('generating the first match path location %s', configPaths[0].path);\n return createConfigFile(configPaths[0]).path;\n}\n\nfunction createConfigFile(configLocation: SetupDirectory): SetupDirectory {\n createConfigFolder(configLocation);\n\n const defaultConfig = updateStorageLinks(configLocation, readDefaultConfig());\n\n fs.writeFileSync(configLocation.path, defaultConfig);\n\n return configLocation;\n}\n\nexport function readDefaultConfig(): string {\n const pathDefaultConf: string = path.resolve(__dirname, 'conf/default.yaml');\n try {\n debug('the path of default config used from %s', pathDefaultConf);\n fs.accessSync(pathDefaultConf, fs.constants.R_OK);\n debug('configuration file has enough permissions for reading');\n } catch {\n debug('configuration file does not have enough permissions for reading');\n throw new TypeError('configuration file does not have enough permissions for reading');\n }\n\n return fs.readFileSync(pathDefaultConf, 'utf8');\n}\n\nfunction createConfigFolder(configLocation): void {\n const folder = path.dirname(configLocation.path);\n debug(`creating default config file folder at %o`, folder);\n fs.mkdirSync(folder, { recursive: true });\n debug(`folder %o created`, folder);\n}\n\n/**\n * Update the storage links to the new location if it is necessary.\n * @param configLocation\n * @param defaultConfig\n * @returns\n */\nfunction updateStorageLinks(configLocation: SetupDirectory, defaultConfig: string): string {\n debug('checking storage links for %s and type %s', configLocation.path, configLocation.type);\n if (configLocation.type !== XDG) {\n debug(`skip storage override for %s`, configLocation.type);\n return defaultConfig;\n }\n\n // $XDG_DATA_HOME defines the base directory relative to which user specific data\n // files should be stored, If $XDG_DATA_HOME is either not set or empty, a default\n // equal to $HOME/.local/share should be used.\n let dataDir =\n process.env.XDG_DATA_HOME || path.join(process.env.HOME as string, '.local', 'share');\n if (folderExists(dataDir)) {\n debug(`previous storage located`);\n debug(`update storage links to %s`, dataDir);\n dataDir = path.resolve(path.join(dataDir, pkgJSON.name, 'storage'));\n return defaultConfig.replace(/^storage: .\\/storage$/m, `storage: ${dataDir}`);\n }\n debug(`could not find a previous storage location, skip override`);\n return defaultConfig;\n}\n\n/**\n * Return a list of configuration locations by platform.\n * @returns\n */\nfunction getConfigPaths(): SetupDirectory[] {\n const listPaths: (SetupDirectory | void)[] = [\n getXDGDirectory(),\n getWindowsDirectory(),\n getRelativeDefaultDirectory(),\n getOldDirectory(),\n ];\n\n return listPaths.reduce(function (acc, currentValue: SetupDirectory | void): SetupDirectory[] {\n if (typeof currentValue !== 'undefined') {\n debug(\n 'posible directory path generated %s for type %s',\n currentValue?.path,\n currentValue.type\n );\n acc.push(currentValue);\n }\n return acc;\n }, [] as SetupDirectory[]);\n}\n\n/**\n * Get XDG_CONFIG_HOME or HOME location (usually unix)\n *\n * The XDG_CONFIG_HOME environment variable is also part of the XDG Base Directory Specification,\n * which aims to standardize the locations where applications store configuration files and other\n * user-specific data on Unix-like operating systems.\n *\n *\n *\n * https://specifications.freedesktop.org/basedir-spec/latest/\n *\n *\n * @returns\n */\nconst getXDGDirectory = (): SetupDirectory | void => {\n const xDGConfigPath =\n process.env.XDG_CONFIG_HOME || (process.env.HOME && path.join(process.env.HOME, '.config'));\n debug('XDGConfig folder path %s', xDGConfigPath);\n if (xDGConfigPath && folderExists(xDGConfigPath)) {\n debug('XDGConfig folder path %s', xDGConfigPath);\n return {\n path: path.join(xDGConfigPath, pkgJSON.name, CONFIG_FILE),\n type: XDG,\n };\n }\n};\n\n/**\n * Detect windows location, APPDATA\n * usually something like C:\\User\\<Build User>\\AppData\\Local\n * @returns\n */\nconst getWindowsDirectory = (): SetupDirectory | void => {\n if (os.platform() === 'win32' && process.env.APPDATA && folderExists(process.env.APPDATA)) {\n debug('windows appdata folder path %s', process.env.APPDATA);\n return {\n path: path.resolve(path.join(process.env.APPDATA, pkgJSON.name, CONFIG_FILE)),\n type: 'win',\n };\n }\n};\n\n/**\n * Return relative directory, this is the default.\n * It will cretate config in your {currentLocation/verdaccio/config.yaml}\n * @returns\n */\nconst getRelativeDefaultDirectory = (): SetupDirectory => {\n const relativePath = path.resolve(path.join('.', pkgJSON.name, CONFIG_FILE));\n debug('relative folder path %s', relativePath);\n return {\n path: relativePath,\n type: 'def',\n };\n};\n\n/**\n * This should never happens, consider it DEPRECATED\n * @returns\n */\nconst getOldDirectory = (): SetupDirectory => {\n const oldPath = path.resolve(path.join('.', CONFIG_FILE));\n debug('old folder path %s', oldPath);\n return {\n path: oldPath,\n type: 'old',\n };\n};\n\nexport { findConfigFile };\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,GAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,GAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEA,IAAAK,YAAA,GAAAL,OAAA;AAA0D,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1D,MAAMG,WAAW,GAAG,aAAa;AACjC,MAAMC,GAAG,GAAG,KAAK;AACjB;AACA,MAAMC,OAAO,GAAG;EACdC,IAAI,EAAE;AACR,CAAC;AAOD,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,8BAA8B,CAAC;;AAExD;AACA;AACA;AACA;AACA,SAASC,cAAcA,CAACC,UAAmB,EAAU;EACnDH,KAAK,CAAC,8BAA8B,EA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AMW,OAAO,GAAGpD,aAAI,CAACC,OAAO,CAACD,aAAI,CAACiC,IAAI,CAAC,GAAG,EAAE1C,WAAW,CAAC,CAAC;EACzDI,KAAK,CAAC,oBAAoB,EAAEyD,OAAO,CAAC;EACpC,OAAO;IACLpD,IAAI,EAAEoD,OAAO;IACbxB,IAAI,EAAE;EACR,CAAC;AACH,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"config-path.js","names":["_debug","_interopRequireDefault","require","_fs","_lodash","_os","_path","_configUtils","e","__esModule","default","CONFIG_FILE","XDG","pkgJSON","name","debug","buildDebug","findConfigFile","configPath","configLocation","path","resolve","configPaths","getConfigPaths","length","Error","primaryConf","_","find","fileExists","createConfigFile","createConfigFolder","defaultConfig","updateStorageLinks","readDefaultConfig","fs","writeFileSync","pathDefaultConf","__dirname","accessSync","constants","R_OK","TypeError","readFileSync","folder","dirname","mkdirSync","recursive","type","dataDir","process","env","XDG_DATA_HOME","join","HOME","folderExists","replace","listPaths","getXDGDirectory","getWindowsDirectory","getRelativeDefaultDirectory","getOldDirectory","reduce","acc","currentValue","push","xDGConfigPath","XDG_CONFIG_HOME","os","platform","APPDATA","relativePath","oldPath"],"sources":["../src/config-path.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport fs from 'fs';\nimport _ from 'lodash';\nimport os from 'os';\nimport path from 'path';\n\nimport { fileExists, folderExists } from './config-utils';\n\nconst CONFIG_FILE = 'config.yaml';\nconst XDG = 'xdg';\n// eslint-disable-next-line\nconst pkgJSON = {\n name: 'verdaccio',\n};\n\nexport type SetupDirectory = {\n path: string;\n type: 'xdg' | 'win' | 'win32' | 'def' | 'old';\n};\n\nconst debug = buildDebug('verdaccio:config:config-path');\n\n/**\n * Find and get the first config file that match.\n * @return {String} the config file path\n */\nfunction findConfigFile(configPath?: string): string {\n debug('searching for config file %o', configPath);\n if (typeof configPath !== 'undefined') {\n const configLocation = path.resolve(configPath);\n debug('custom location %s', configLocation);\n return configLocation;\n }\n\n const configPaths: SetupDirectory[] = getConfigPaths();\n debug('%o posible locations found', configPaths.length);\n if (configPaths.length === 0) {\n debug('no configuration files can be processed');\n // this should never happens\n throw new Error('no configuration files can be processed');\n }\n\n // find the first location that already exist\n const primaryConf: SetupDirectory | void = _.find(configPaths, (configLocation: SetupDirectory) =>\n fileExists(configLocation.path)\n );\n\n if (typeof primaryConf !== 'undefined') {\n debug('at least one primary location detected at %s', primaryConf?.path);\n return primaryConf.path;\n }\n debug('no previous location found, creating a new one');\n debug('generating the first match path location %s', configPaths[0].path);\n return createConfigFile(configPaths[0]).path;\n}\n\nfunction createConfigFile(configLocation: SetupDirectory): SetupDirectory {\n createConfigFolder(configLocation);\n\n const defaultConfig = updateStorageLinks(configLocation, readDefaultConfig());\n\n fs.writeFileSync(configLocation.path, defaultConfig);\n\n return configLocation;\n}\n\nexport function readDefaultConfig(): string {\n const pathDefaultConf: string = path.resolve(__dirname, 'conf/default.yaml');\n try {\n debug('the path of default config used from %s', pathDefaultConf);\n fs.accessSync(pathDefaultConf, fs.constants.R_OK);\n debug('configuration file has enough permissions for reading');\n } catch {\n debug('configuration file does not have enough permissions for reading');\n throw new TypeError('configuration file does not have enough permissions for reading');\n }\n\n return fs.readFileSync(pathDefaultConf, 'utf8');\n}\n\nfunction createConfigFolder(configLocation): void {\n const folder = path.dirname(configLocation.path);\n debug(`creating default config file folder at %o`, folder);\n fs.mkdirSync(folder, { recursive: true });\n debug(`folder %o created`, folder);\n}\n\n/**\n * Update the storage links to the new location if it is necessary.\n * @param configLocation\n * @param defaultConfig\n * @returns\n */\nfunction updateStorageLinks(configLocation: SetupDirectory, defaultConfig: string): string {\n debug('checking storage links for %s and type %s', configLocation.path, configLocation.type);\n if (configLocation.type !== XDG) {\n debug(`skip storage override for %s`, configLocation.type);\n return defaultConfig;\n }\n\n // $XDG_DATA_HOME defines the base directory relative to which user specific data\n // files should be stored, If $XDG_DATA_HOME is either not set or empty, a default\n // equal to $HOME/.local/share should be used.\n let dataDir =\n process.env.XDG_DATA_HOME || path.join(process.env.HOME as string, '.local', 'share');\n if (folderExists(dataDir)) {\n debug(`previous storage located`);\n debug(`update storage links to %s`, dataDir);\n dataDir = path.resolve(path.join(dataDir, pkgJSON.name, 'storage'));\n return defaultConfig.replace(/^storage: .\\/storage$/m, `storage: ${dataDir}`);\n }\n debug(`could not find a previous storage location, skip override`);\n return defaultConfig;\n}\n\n/**\n * Return a list of configuration locations by platform.\n * @returns\n */\nfunction getConfigPaths(): SetupDirectory[] {\n const listPaths: (SetupDirectory | void)[] = [\n getXDGDirectory(),\n getWindowsDirectory(),\n getRelativeDefaultDirectory(),\n getOldDirectory(),\n ];\n\n return listPaths.reduce(function (acc, currentValue: SetupDirectory | void): SetupDirectory[] {\n if (typeof currentValue !== 'undefined') {\n debug(\n 'posible directory path generated %s for type %s',\n currentValue?.path,\n currentValue.type\n );\n acc.push(currentValue);\n }\n return acc;\n }, [] as SetupDirectory[]);\n}\n\n/**\n * Get XDG_CONFIG_HOME or HOME location (usually unix)\n *\n * The XDG_CONFIG_HOME environment variable is also part of the XDG Base Directory Specification,\n * which aims to standardize the locations where applications store configuration files and other\n * user-specific data on Unix-like operating systems.\n *\n *\n *\n * https://specifications.freedesktop.org/basedir-spec/latest/\n *\n *\n * @returns\n */\nconst getXDGDirectory = (): SetupDirectory | void => {\n const xDGConfigPath =\n process.env.XDG_CONFIG_HOME || (process.env.HOME && path.join(process.env.HOME, '.config'));\n debug('XDGConfig folder path %s', xDGConfigPath);\n if (xDGConfigPath && folderExists(xDGConfigPath)) {\n debug('XDGConfig folder path %s', xDGConfigPath);\n return {\n path: path.join(xDGConfigPath, pkgJSON.name, CONFIG_FILE),\n type: XDG,\n };\n }\n};\n\n/**\n * Detect windows location, APPDATA\n * usually something like C:\\User\\<Build User>\\AppData\\Local\n * @returns\n */\nconst getWindowsDirectory = (): SetupDirectory | void => {\n if (os.platform() === 'win32' && process.env.APPDATA && folderExists(process.env.APPDATA)) {\n debug('windows appdata folder path %s', process.env.APPDATA);\n return {\n path: path.resolve(path.join(process.env.APPDATA, pkgJSON.name, CONFIG_FILE)),\n type: 'win',\n };\n }\n};\n\n/**\n * Return relative directory, this is the default.\n * It will cretate config in your {currentLocation/verdaccio/config.yaml}\n * @returns\n */\nconst getRelativeDefaultDirectory = (): SetupDirectory => {\n const relativePath = path.resolve(path.join('.', pkgJSON.name, CONFIG_FILE));\n debug('relative folder path %s', relativePath);\n return {\n path: relativePath,\n type: 'def',\n };\n};\n\n/**\n * This should never happens, consider it DEPRECATED\n * @returns\n */\nconst getOldDirectory = (): SetupDirectory => {\n const oldPath = path.resolve(path.join('.', CONFIG_FILE));\n debug('old folder path %s', oldPath);\n return {\n path: oldPath,\n type: 'old',\n };\n};\n\nexport { findConfigFile };\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,GAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,GAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEA,IAAAK,YAAA,GAAAL,OAAA;AAA0D,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1D,MAAMG,WAAW,GAAG,aAAa;AACjC,MAAMC,GAAG,GAAG,KAAK;AACjB;AACA,MAAMC,OAAO,GAAG;EACdC,IAAI,EAAE;AACR,CAAC;AAOD,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,8BAA8B,CAAC;;AAExD;AACA;AACA;AACA;AACA,SAASC,cAAcA,CAACC,UAAmB,EAAU;EACnDH,KAAK,CAAC,8BAA8B,EAAEG,UAAU,CAAC;EACjD,IAAI,OAAOA,UAAU,KAAK,WAAW,EAAE;IACrC,MAAMC,cAAc,GAAGC,aAAI,CAACC,OAAO,CA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ACLpD,IAAI,EAAEoD,OAAO;IACbxB,IAAI,EAAE;EACR,CAAC;AACH,CAAC","ignoreList":[]}
|
package/build/config.js
CHANGED
|
@@ -53,14 +53,12 @@ class Config {
|
|
|
53
53
|
configOverrideOptions = {
|
|
54
54
|
forceMigrateToSecureLegacySignature: true
|
|
55
55
|
}) {
|
|
56
|
-
var _config$flags$searchR, _config$flags, _config$flags$changeP, _config$flags2;
|
|
57
56
|
const self = this;
|
|
58
57
|
this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;
|
|
59
58
|
if (!config.configPath) {
|
|
60
|
-
var _config$config_path;
|
|
61
59
|
// backport self_path for previous to version 6
|
|
62
60
|
// @ts-expect-error
|
|
63
|
-
config.configPath =
|
|
61
|
+
config.configPath = config.config_path ?? config.self_path;
|
|
64
62
|
if (!config.configPath) {
|
|
65
63
|
throw new Error('configPath property is required');
|
|
66
64
|
}
|
|
@@ -79,8 +77,8 @@ class Config {
|
|
|
79
77
|
}), config.security);
|
|
80
78
|
this.serverSettings = _serverSettings.default;
|
|
81
79
|
this.flags = {
|
|
82
|
-
searchRemote:
|
|
83
|
-
changePassword:
|
|
80
|
+
searchRemote: config.flags?.searchRemote ?? true,
|
|
81
|
+
changePassword: config.flags?.changePassword ?? false
|
|
84
82
|
};
|
|
85
83
|
this.user_agent = config.user_agent;
|
|
86
84
|
for (const configProp in config) {
|
|
@@ -95,7 +93,7 @@ class Config {
|
|
|
95
93
|
}
|
|
96
94
|
this.userRateLimit = {
|
|
97
95
|
...defaultUserRateLimiting,
|
|
98
|
-
...
|
|
96
|
+
...config?.userRateLimit
|
|
99
97
|
};
|
|
100
98
|
|
|
101
99
|
// some weird shell scripts are valid yaml files parsed as string
|
|
@@ -191,12 +189,11 @@ class Config {
|
|
|
191
189
|
this.secret = secret;
|
|
192
190
|
return this.secret;
|
|
193
191
|
} else {
|
|
194
|
-
var _this$secret;
|
|
195
192
|
// generate a new a secret key
|
|
196
193
|
// FUTURE: this might be an external secret key, perhaps within config file?
|
|
197
194
|
debug('generating a new secret key');
|
|
198
195
|
this.secret = (0, _token.generateRandomSecretKey)();
|
|
199
|
-
debug('generated a new secret key length %s',
|
|
196
|
+
debug('generated a new secret key length %s', this.secret?.length);
|
|
200
197
|
return this.secret;
|
|
201
198
|
}
|
|
202
199
|
}
|
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","e","__esModule","default","strategicConfigProps","allowedEnvConfig","debug","buildDebug","WEB_TITLE","exports","defaultUserRateLimiting","windowMs","max","isNodeVersionGreaterThan21","major","minor","process","versions","node","split","map","Number","TOKEN_VALID_LENGTH","Config","constructor","config","configOverrideOptions","forceMigrateToSecureLegacySignature","_config$flags$searchR","_config$flags","_config$flags$changeP","_config$flags2","self","storage","env","VERDACCIO_STORAGE_PATH","configPath","_config$config_path","config_path","self_path","Error","plugins","security","_","merge","defaultSecurity","api","migrateToSecureLegacySignature","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","getMigrateToSecureLegacySignature","getConfigPath","getMatchedPackagesSpec","pkgName","checkSecretKey","secret","isEmpty","length","generateRandomSecretKey","warningUtils","emit","Codes","VERWAR007","_this$secret"],"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\nexport function isNodeVersionGreaterThan21() {\n const [major, minor] = process.versions.node.split('.').map(Number);\n return major > 21 || (major === 21 && minor >= 0);\n}\n\nconst TOKEN_VALID_LENGTH = 32;\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 private configOverrideOptions: { forceMigrateToSecureLegacySignature: boolean };\n // @ts-ignore\n public secret: string;\n public flags: FlagsConfig;\n public userRateLimit: RateLimit;\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 configOverrideOptions = { forceMigrateToSecureLegacySignature: true }\n ) {\n const self = this;\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.configOverrideOptions = configOverrideOptions;\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(\n // override the default security configuration via constructor\n _.merge(defaultSecurity, {\n api: {\n migrateToSecureLegacySignature:\n this.configOverrideOptions.forceMigrateToSecureLegacySignature,\n },\n }),\n config.security\n );\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 getMigrateToSecureLegacySignature() {\n return this.security.api.migrateToSecureLegacySignature;\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 * Verify if the secret complies with the required structure\n * - If the secret is not provided, it will generate a new one\n * - For any Node.js version the new secret will be 32 characters long (to allow compatibility with modern Node.js versions)\n * - If the secret is provided:\n * - If Node.js 22 or higher, the secret must be 32 characters long thus the application will fail on startup\n * - If Node.js 21 or lower, the secret will be used as is but will display a deprecation warning\n * - If the property `security.api.migrateToSecureLegacySignature` is provided and set to true, the secret will be\n * generated with the new signature model\n * @secret external secret key\n */\n public checkSecretKey(secret?: string): string {\n debug('checking secret key init');\n if (typeof secret === 'string' && _.isEmpty(secret) === false) {\n debug('checking secret key length %s', secret.length);\n if (secret.length > TOKEN_VALID_LENGTH) {\n if (isNodeVersionGreaterThan21()) {\n debug('is node version greater than 21');\n if (this.getMigrateToSecureLegacySignature() === true) {\n this.secret = generateRandomSecretKey();\n debug('rewriting secret key with length %s', this.secret.length);\n return this.secret;\n }\n // oops, user needs to generate a new secret key\n debug(\n 'secret does not comply with the required length, current length %d, application will fail on startup',\n secret.length\n );\n throw new Error(\n `Invalid storage secret key length, must be 32 characters long but is ${secret.length}. \n The secret length in Node.js 22 or higher must be 32 characters long. Please consider generate a new one. \n Learn more at https://verdaccio.org/docs/configuration/#.verdaccio-db`\n );\n } else {\n debug('is node version lower than 22');\n if (this.getMigrateToSecureLegacySignature() === true) {\n this.secret = generateRandomSecretKey();\n debug('rewriting secret key with length %s', this.secret.length);\n return this.secret;\n }\n debug('triggering deprecation warning for secret key length %s', secret.length);\n // still using Node.js versions previous to 22, but we need to emit a deprecation warning\n // deprecation warning, secret key is too long and must be 32\n // this will be removed in the next major release and will produce an error\n warningUtils.emit(Codes.VERWAR007);\n this.secret = secret;\n return this.secret;\n }\n } else if (secret.length === TOKEN_VALID_LENGTH) {\n debug('detected valid secret key length %s', secret.length);\n this.secret = secret;\n return this.secret;\n }\n debug('reusing previous key with length %s', secret.length);\n this.secret = secret;\n return this.secret;\n } else {\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 this.secret = generateRandomSecretKey();\n debug('generated a new secret key length %s', this.secret?.length);\n\n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,CAACE,MAAM,CAAC;MAC3D,IAAI,CAACF,MAAM,GAAGA,MAAM;MACpB,OAAO,IAAI,CAACA,MAAM;IACpB,CAAC,MAAM;MAAA,IAAAQ,YAAA;MACL;MACA;MACA9E,KAAK,CAAC,6BAA6B,CAAC;MACpC,IAAI,CAACsE,MAAM,GAAG,IAAAG,8BAAuB,EAAC,CAAC;MACvCzE,KAAK,CAAC,sCAAsC,GAAA8E,YAAA,GAAE,IAAI,CAACR,MAAM,cAAAQ,YAAA,uBAAXA,YAAA,CAAaN,MAAM,CAAC;MAElE,OAAO,IAAI,CAACF,MAAM;IACpB;EACF;AACF;AAACnE,OAAA,CAAAc,MAAA,GAAAA,MAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"config.js","names":["_assert","_interopRequireDefault","require","_debug","_lodash","_core","_warningUtils","_utils","_agent","_packageAccess","_security","_serverSettings","_token","_uplinks","e","__esModule","default","strategicConfigProps","allowedEnvConfig","debug","buildDebug","WEB_TITLE","exports","defaultUserRateLimiting","windowMs","max","isNodeVersionGreaterThan21","major","minor","process","versions","node","split","map","Number","TOKEN_VALID_LENGTH","Config","constructor","config","configOverrideOptions","forceMigrateToSecureLegacySignature","self","storage","env","VERDACCIO_STORAGE_PATH","configPath","config_path","self_path","Error","plugins","security","_","merge","defaultSecurity","api","migrateToSecureLegacySignature","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","getMigrateToSecureLegacySignature","getConfigPath","getMatchedPackagesSpec","pkgName","checkSecretKey","secret","isEmpty","length","generateRandomSecretKey","warningUtils","emit","Codes","VERWAR007"],"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\nexport function isNodeVersionGreaterThan21() {\n const [major, minor] = process.versions.node.split('.').map(Number);\n return major > 21 || (major === 21 && minor >= 0);\n}\n\nconst TOKEN_VALID_LENGTH = 32;\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 private configOverrideOptions: { forceMigrateToSecureLegacySignature: boolean };\n // @ts-ignore\n public secret: string;\n public flags: FlagsConfig;\n public userRateLimit: RateLimit;\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 configOverrideOptions = { forceMigrateToSecureLegacySignature: true }\n ) {\n const self = this;\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.configOverrideOptions = configOverrideOptions;\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(\n // override the default security configuration via constructor\n _.merge(defaultSecurity, {\n api: {\n migrateToSecureLegacySignature:\n this.configOverrideOptions.forceMigrateToSecureLegacySignature,\n },\n }),\n config.security\n );\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 getMigrateToSecureLegacySignature() {\n return this.security.api.migrateToSecureLegacySignature;\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 * Verify if the secret complies with the required structure\n * - If the secret is not provided, it will generate a new one\n * - For any Node.js version the new secret will be 32 characters long (to allow compatibility with modern Node.js versions)\n * - If the secret is provided:\n * - If Node.js 22 or higher, the secret must be 32 characters long thus the application will fail on startup\n * - If Node.js 21 or lower, the secret will be used as is but will display a deprecation warning\n * - If the property `security.api.migrateToSecureLegacySignature` is provided and set to true, the secret will be\n * generated with the new signature model\n * @secret external secret key\n */\n public checkSecretKey(secret?: string): string {\n debug('checking secret key init');\n if (typeof secret === 'string' && _.isEmpty(secret) === false) {\n debug('checking secret key length %s', secret.length);\n if (secret.length > TOKEN_VALID_LENGTH) {\n if (isNodeVersionGreaterThan21()) {\n debug('is node version greater than 21');\n if (this.getMigrateToSecureLegacySignature() === true) {\n this.secret = generateRandomSecretKey();\n debug('rewriting secret key with length %s', this.secret.length);\n return this.secret;\n }\n // oops, user needs to generate a new secret key\n debug(\n 'secret does not comply with the required length, current length %d, application will fail on startup',\n secret.length\n );\n throw new Error(\n `Invalid storage secret key length, must be 32 characters long but is ${secret.length}. \n The secret length in Node.js 22 or higher must be 32 characters long. Please consider generate a new one. \n Learn more at https://verdaccio.org/docs/configuration/#.verdaccio-db`\n );\n } else {\n debug('is node version lower than 22');\n if (this.getMigrateToSecureLegacySignature() === true) {\n this.secret = generateRandomSecretKey();\n debug('rewriting secret key with length %s', this.secret.length);\n return this.secret;\n }\n debug('triggering deprecation warning for secret key length %s', secret.length);\n // still using Node.js versions previous to 22, but we need to emit a deprecation warning\n // deprecation warning, secret key is too long and must be 32\n // this will be removed in the next major release and will produce an error\n warningUtils.emit(Codes.VERWAR007);\n this.secret = secret;\n return this.secret;\n }\n } else if (secret.length === TOKEN_VALID_LENGTH) {\n debug('detected valid secret key length %s', secret.length);\n this.secret = secret;\n return this.secret;\n }\n debug('reusing previous key with length %s', secret.length);\n this.secret = secret;\n return this.secret;\n } else {\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 this.secret = generateRandomSecretKey();\n debug('generated a new secret key length %s', this.secret?.length);\n\n return this.secret;\n }\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,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEvE,MAAMG,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,GAAAC,OAAA,CAAAD,SAAA,GAAG,WAAW;;AAEpC;AACO,MAAME,uBAAuB,GAAAD,OAAA,CAAAC,uBAAA,GAAG;EACrCC,QAAQ,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;EAAE;EAC1BC,GAAG,EAAE;AACP,CAAC;AAEM,SAASC,0BAA0BA,CAAA,EAAG;EAC3C,MAAM,CAACC,KAAK,EAAEC,KAAK,CAAC,GAAGC,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,8BAAuB,EAAC,CAAC;MACvCpE,KAAK,CAAC,sCAAsC,EAAE,IAAI,CAACiE,MAAM,EAAEE,MAAM,CAAC;MAElE,OAAO,IAAI,CAACF,MAAM;IACpB;EACF;AACF;AAAC9D,OAAA,CAAAc,MAAA,GAAAA,MAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/config",
|
|
3
|
-
"version": "8.0.0-next-8.
|
|
3
|
+
"version": "8.0.0-next-8.2",
|
|
4
4
|
"description": "logger",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"verdaccio"
|
|
27
27
|
],
|
|
28
28
|
"engines": {
|
|
29
|
-
"node": ">=
|
|
29
|
+
"node": ">=18"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@verdaccio/core": "8.0.0-next-8.
|
|
33
|
-
"@verdaccio/utils": "7.0
|
|
32
|
+
"@verdaccio/core": "8.0.0-next-8.2",
|
|
33
|
+
"@verdaccio/utils": "7.1.0-next-8.2",
|
|
34
34
|
"debug": "4.3.7",
|
|
35
35
|
"js-yaml": "4.1.0",
|
|
36
36
|
"lodash": "4.17.21",
|