@verdaccio/config 6.0.0-6-next.62 → 6.0.0-6-next.63

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @verdaccio/config
2
2
 
3
+ ## 6.0.0-6-next.63
4
+
5
+ ### Minor Changes
6
+
7
+ - ddb6a223: feat: signature package
8
+ - dc571aab: feat: add forceEnhancedLegacySignature
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [dc571aab]
13
+ - @verdaccio/core@6.0.0-6-next.63
14
+ - @verdaccio/utils@6.0.0-6-next.31
15
+
3
16
  ## 6.0.0-6-next.62
4
17
 
5
18
  ### Patch Changes
@@ -27,7 +27,6 @@ const debug = (0, _debug.default)('verdaccio:config');
27
27
  * @return {String} the config file path
28
28
  */
29
29
  function findConfigFile(configPath) {
30
- // console.log(process.env);
31
30
  if (typeof configPath !== 'undefined') {
32
31
  return _path.default.resolve(configPath);
33
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config-path.js","names":["CONFIG_FILE","XDG","WIN","WIN32","pkgJSON","name","debug","buildDebug","findConfigFile","configPath","path","resolve","configPaths","getConfigPaths","length","_","isEmpty","Error","primaryConf","find","configLocation","fileExists","createConfigFile","head","createConfigFolder","defaultConfig","updateStorageLinks","readDefaultConfig","fs","writeFileSync","pathDefaultConf","__dirname","accessSync","constants","R_OK","TypeError","readFileSync","CHARACTER_ENCODING","UTF8","mkdirSync","dirname","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","platform","APPDATA"],"sources":["../src/config-path.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport fs from 'fs';\nimport _ from 'lodash';\nimport path from 'path';\n\nimport { CHARACTER_ENCODING } from '@verdaccio/core';\n\nimport { fileExists, folderExists } from './config-utils';\n\nconst CONFIG_FILE = 'config.yaml';\nconst XDG = 'xdg';\nconst WIN = 'win';\nconst WIN32 = 'win32';\n// eslint-disable-next-line\nconst pkgJSON = {\n name: 'verdaccio',\n};\n\nexport type SetupDirectory = {\n path: string;\n type: string;\n};\n\nconst debug = buildDebug('verdaccio:config');\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 // console.log(process.env);\n if (typeof configPath !== 'undefined') {\n return path.resolve(configPath);\n }\n\n const configPaths: SetupDirectory[] = getConfigPaths();\n debug('%o posible locations found', configPaths.length);\n if (_.isEmpty(configPaths)) {\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('previous location exist already %s', primaryConf?.path);\n return primaryConf.path;\n }\n\n // @ts-ignore\n return createConfigFile(_.head(configPaths)).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(): Buffer {\n const pathDefaultConf: string = path.resolve(__dirname, 'conf/default.yaml');\n try {\n debug('default configuration file %s', pathDefaultConf);\n fs.accessSync(pathDefaultConf, fs.constants.R_OK);\n } catch {\n throw new TypeError('configuration file does not have enough permissions for reading');\n }\n // @ts-ignore\n return fs.readFileSync(pathDefaultConf, CHARACTER_ENCODING.UTF8);\n}\n\nfunction createConfigFolder(configLocation): void {\n fs.mkdirSync(path.dirname(configLocation.path), { recursive: true });\n debug(`Creating default config file in %o`, configLocation?.path);\n}\n\nfunction updateStorageLinks(configLocation, defaultConfig): string {\n if (configLocation.type !== XDG) {\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('directory detected path %s for type %s', currentValue?.path, currentValue.type);\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 * @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 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 (process.platform === WIN32 && process.env.APPDATA && folderExists(process.env.APPDATA)) {\n debug('is windows appdata: %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 return {\n path: path.resolve(path.join('.', pkgJSON.name, CONFIG_FILE)),\n type: 'def',\n };\n};\n\n/**\n * This should never happens, consider it DEPRECATED\n * @returns\n */\nconst getOldDirectory = (): SetupDirectory => {\n return {\n path: path.resolve(path.join('.', CONFIG_FILE)),\n type: 'old',\n };\n};\n\nexport { findConfigFile };\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AAEA;AAEA;AAA0D;AAE1D,MAAMA,WAAW,GAAG,aAAa;AACjC,MAAMC,GAAG,GAAG,KAAK;AACjB,MAAMC,GAAG,GAAG,KAAK;AACjB,MAAMC,KAAK,GAAG,OAAO;AACrB;AACA,MAAMC,OAAO,GAAG;EACdC,IAAI,EAAE;AACR,CAAC;AAOD,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,kBAAkB,CAAC;;AAE5C;AACA;AACA;AACA;AACA,SAASC,cAAc,CAACC,UAAmB,EAAU;EACnD;EACA,IAAI,OAAOA,UAAU,KAAK,WAAW,EAAE;IACrC,OAAOC,aAAI,CAACC,OAAO,CAACF,UAAU,CAAC;EACjC;EAEA,MAAMG,WAA6B,GAAGC,cAAc,EAAE;EACtDP,KAAK,CAAC,4BAA4B,EAAEM,WAAW,CAACE,MAAM,CAAC;EACvD,IAAIC,eAAC,CAACC,OAAO,CAACJ,WAAW,CAAC,EAAE;IAC1B;IACA,MAAM,IAAIK,KAAK,CAAC,yCAAyC,CAAC;EAC5D;;EAEA;EACA,MAAMC,WAAkC,GAAGH,eAAC,CAACI,IAAI,CAACP,WAAW,EAAGQ,cAA8B,IAC5F,IAAAC,uBAAU,EAACD,cAAc,CAACV,IAAI,CAAC,CAChC;EAED,IAAI,OAAOQ,WAAW,KAAK,WAAW,EAAE;IACtCZ,KAAK,CAAC,oCAAoC,EAAEY,WAAW,aAAXA,WAAW,uBAAXA,WAAW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AE/C,WAAW,CAAC,CAAC;IAC/C0C,IAAI,EAAE;EACR,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"config-path.js","names":["CONFIG_FILE","XDG","WIN","WIN32","pkgJSON","name","debug","buildDebug","findConfigFile","configPath","path","resolve","configPaths","getConfigPaths","length","_","isEmpty","Error","primaryConf","find","configLocation","fileExists","createConfigFile","head","createConfigFolder","defaultConfig","updateStorageLinks","readDefaultConfig","fs","writeFileSync","pathDefaultConf","__dirname","accessSync","constants","R_OK","TypeError","readFileSync","CHARACTER_ENCODING","UTF8","mkdirSync","dirname","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","platform","APPDATA"],"sources":["../src/config-path.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport fs from 'fs';\nimport _ from 'lodash';\nimport path from 'path';\n\nimport { CHARACTER_ENCODING } from '@verdaccio/core';\n\nimport { fileExists, folderExists } from './config-utils';\n\nconst CONFIG_FILE = 'config.yaml';\nconst XDG = 'xdg';\nconst WIN = 'win';\nconst WIN32 = 'win32';\n// eslint-disable-next-line\nconst pkgJSON = {\n name: 'verdaccio',\n};\n\nexport type SetupDirectory = {\n path: string;\n type: string;\n};\n\nconst debug = buildDebug('verdaccio:config');\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 if (typeof configPath !== 'undefined') {\n return path.resolve(configPath);\n }\n\n const configPaths: SetupDirectory[] = getConfigPaths();\n debug('%o posible locations found', configPaths.length);\n if (_.isEmpty(configPaths)) {\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('previous location exist already %s', primaryConf?.path);\n return primaryConf.path;\n }\n\n // @ts-ignore\n return createConfigFile(_.head(configPaths)).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(): Buffer {\n const pathDefaultConf: string = path.resolve(__dirname, 'conf/default.yaml');\n try {\n debug('default configuration file %s', pathDefaultConf);\n fs.accessSync(pathDefaultConf, fs.constants.R_OK);\n } catch {\n throw new TypeError('configuration file does not have enough permissions for reading');\n }\n // @ts-ignore\n return fs.readFileSync(pathDefaultConf, CHARACTER_ENCODING.UTF8);\n}\n\nfunction createConfigFolder(configLocation): void {\n fs.mkdirSync(path.dirname(configLocation.path), { recursive: true });\n debug(`Creating default config file in %o`, configLocation?.path);\n}\n\nfunction updateStorageLinks(configLocation, defaultConfig): string {\n if (configLocation.type !== XDG) {\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('directory detected path %s for type %s', currentValue?.path, currentValue.type);\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 * @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 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 (process.platform === WIN32 && process.env.APPDATA && folderExists(process.env.APPDATA)) {\n debug('is windows appdata: %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 return {\n path: path.resolve(path.join('.', pkgJSON.name, CONFIG_FILE)),\n type: 'def',\n };\n};\n\n/**\n * This should never happens, consider it DEPRECATED\n * @returns\n */\nconst getOldDirectory = (): SetupDirectory => {\n return {\n path: path.resolve(path.join('.', CONFIG_FILE)),\n type: 'old',\n };\n};\n\nexport { findConfigFile };\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AAEA;AAEA;AAA0D;AAE1D,MAAMA,WAAW,GAAG,aAAa;AACjC,MAAMC,GAAG,GAAG,KAAK;AACjB,MAAMC,GAAG,GAAG,KAAK;AACjB,MAAMC,KAAK,GAAG,OAAO;AACrB;AACA,MAAMC,OAAO,GAAG;EACdC,IAAI,EAAE;AACR,CAAC;AAOD,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,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AO,CAACC,GAAG,CAACkB,OAAO,CAAC;IACpD,OAAO;MACLrD,IAAI,EAAEA,aAAI,CAACC,OAAO,CAACD,aAAI,CAACqC,IAAI,CAACH,OAAO,CAACC,GAAG,CAACkB,OAAO,EAAE3D,OAAO,CAACC,IAAI,EAAEL,WAAW,CAAC,CAAC;MAC7E0C,IAAI,EAAExC;IACR,CAAC;EACH;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMoD,2BAA2B,GAAG,MAAsB;EACxD,OAAO;IACL5C,IAAI,EAAEA,aAAI,CAACC,OAAO,CAACD,aAAI,CAACqC,IAAI,CAAC,GAAG,EAAE3C,OAAO,CAACC,IAAI,EAAEL,WAAW,CAAC,CAAC;IAC7D0C,IAAI,EAAE;EACR,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMa,eAAe,GAAG,MAAsB;EAC5C,OAAO;IACL7C,IAAI,EAAEA,aAAI,CAACC,OAAO,CAACD,aAAI,CAACqC,IAAI,CAAC,GAAG,EAAE/C,WAAW,CAAC,CAAC;IAC/C0C,IAAI,EAAE;EACR,CAAC;AACH,CAAC"}
package/build/config.d.ts CHANGED
@@ -14,8 +14,11 @@ declare class Config implements AppConfig {
14
14
  users: any;
15
15
  auth: AuthConf;
16
16
  server_id: string;
17
- config_path: string;
18
17
  configPath: string;
18
+ /**
19
+ * @deprecated use configPath or config.getConfigPath();
20
+ */
21
+ self_path: string;
19
22
  storage: string | void;
20
23
  plugins: string | void | null;
21
24
  security: Security;
@@ -23,15 +26,20 @@ declare class Config implements AppConfig {
23
26
  secret: string;
24
27
  flags: FlagsConfig;
25
28
  userRateLimit: RateLimit;
29
+ private configOptions;
26
30
  constructor(config: ConfigYaml & {
27
31
  config_path: string;
32
+ }, configOptions?: {
33
+ forceEnhancedLegacySignature: boolean;
28
34
  });
35
+ getConfigPath(): string;
29
36
  /**
30
37
  * Check for package spec
31
38
  */
32
39
  getMatchedPackagesSpec(pkgName: string): PackageAccess | void;
33
40
  /**
34
41
  * Store or create whether receive a secret key
42
+ * @secret external secret key
35
43
  */
36
44
  checkSecretKey(secret?: string): string;
37
45
  }
package/build/config.js CHANGED
@@ -8,6 +8,7 @@ var _assert = _interopRequireDefault(require("assert"));
8
8
  var _debug = _interopRequireDefault(require("debug"));
9
9
  var _lodash = _interopRequireDefault(require("lodash"));
10
10
  var _core = require("@verdaccio/core");
11
+ var _warningUtils = require("@verdaccio/core/build/warning-utils");
11
12
  var _utils = require("@verdaccio/utils");
12
13
  var _agent = require("./agent");
13
14
  var _packageAccess = require("./package-access");
@@ -34,19 +35,30 @@ const defaultUserRateLimiting = {
34
35
  */
35
36
  exports.defaultUserRateLimiting = defaultUserRateLimiting;
36
37
  class Config {
37
- // @deprecated use configPath instead
38
+ /**
39
+ * @deprecated use configPath or config.getConfigPath();
40
+ */
38
41
 
39
42
  // @ts-ignore
40
43
 
41
- constructor(config) {
42
- var _config$config_path, _config$flags$searchR, _config$flags;
44
+ constructor(config, configOptions = {
45
+ forceEnhancedLegacySignature: true
46
+ }) {
47
+ var _config$flags$searchR, _config$flags;
43
48
  const self = this;
49
+ this.configOptions = configOptions;
44
50
  this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;
45
51
  if (!config.configPath) {
46
- throw new Error('config_path is required');
52
+ var _config$config_path;
53
+ // backport self_path for previous to version 6
54
+ // @ts-expect-error
55
+ config.configPath = (_config$config_path = config.config_path) !== null && _config$config_path !== void 0 ? _config$config_path : config.self_path;
56
+ if (!config.configPath) {
57
+ throw new Error('configPath property is required');
58
+ }
47
59
  }
48
- this.config_path = (_config$config_path = config.config_path) !== null && _config$config_path !== void 0 ? _config$config_path : config.configPath;
49
60
  this.configPath = config.configPath;
61
+ this.self_path = this.configPath;
50
62
  debug('config path: %s', this.configPath);
51
63
  this.plugins = config.plugins;
52
64
  this.security = _lodash.default.merge(_security.defaultSecurity, config.security);
@@ -96,6 +108,9 @@ class Config {
96
108
  this.server_id = (0, _utils.generateRandomHexString)(6);
97
109
  }
98
110
  }
111
+ getConfigPath() {
112
+ return this.configPath;
113
+ }
99
114
 
100
115
  /**
101
116
  * Check for package spec
@@ -107,18 +122,32 @@ class Config {
107
122
 
108
123
  /**
109
124
  * Store or create whether receive a secret key
125
+ * @secret external secret key
110
126
  */
111
127
  checkSecretKey(secret) {
128
+ var _this$secret;
112
129
  debug('check secret key');
113
- if (_lodash.default.isString(secret) && _lodash.default.isEmpty(secret) === false) {
130
+ if (typeof secret === 'string' && _lodash.default.isEmpty(secret) === false) {
114
131
  this.secret = secret;
115
132
  debug('reusing previous key');
116
133
  return secret;
117
134
  }
118
- // it generates a secret key
135
+ // generate a new a secret key
119
136
  // FUTURE: this might be an external secret key, perhaps within config file?
120
137
  debug('generate a new key');
121
- this.secret = (0, _token.generateRandomSecretKey)();
138
+ //
139
+ if (this.configOptions.forceEnhancedLegacySignature) {
140
+ this.secret = (0, _token.generateRandomSecretKey)();
141
+ } else {
142
+ this.secret = this.security.enhancedLegacySignature === true ? (0, _token.generateRandomSecretKey)() : (0, _utils.generateRandomHexString)(32);
143
+ // set this to false allow use old token signature and is not recommended
144
+ // only use for migration reasons, major release will remove this property and
145
+ // set it by default
146
+ if (this.security.enhancedLegacySignature === false) {
147
+ _core.warningUtils.emit(_warningUtils.Codes.VERWAR005);
148
+ }
149
+ }
150
+ debug('generated a new secret key %s', (_this$secret = this.secret) === null || _this$secret === void 0 ? void 0 : _this$secret.length);
122
151
  return this.secret;
123
152
  }
124
153
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":["strategicConfigProps","allowedEnvConfig","debug","buildDebug","WEB_TITLE","defaultUserRateLimiting","windowMs","max","Config","constructor","config","self","storage","process","env","VERDACCIO_STORAGE_PATH","configPath","Error","config_path","plugins","security","_","merge","defaultSecurity","serverSettings","flags","searchRemote","user_agent","configProp","getUserAgent","userRateLimit","assert","isObject","APP_ERROR","CONFIG_NOT_VALID","forEach","x","uplinks","sanityCheckUplinksProps","uplinkSanityCheck","packages","normalisePackageAccess","envConf","toUpperCase","server_id","generateRandomHexString","getMatchedPackagesSpec","pkgName","checkSecretKey","secret","isString","isEmpty","generateRandomSecretKey"],"sources":["../src/config.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { APP_ERROR } from '@verdaccio/core';\nimport {\n Config as AppConfig,\n AuthConf,\n ConfigYaml,\n FlagsConfig,\n PackageAccess,\n PackageList,\n RateLimit,\n Security,\n ServerSettingsConf,\n} from '@verdaccio/types';\nimport { generateRandomHexString, getMatchedPackagesSpec, isObject } from '@verdaccio/utils';\n\nimport { getUserAgent } from './agent';\nimport { normalisePackageAccess } from './package-access';\nimport { defaultSecurity } from './security';\nimport serverSettings from './serverSettings';\nimport { generateRandomSecretKey } from './token';\nimport { sanityCheckUplinksProps, uplinkSanityCheck } from './uplinks';\n\nconst strategicConfigProps = ['uplinks', 'packages'];\nconst allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];\nconst debug = buildDebug('verdaccio:config');\n\nexport const WEB_TITLE = 'Verdaccio';\n\n// we limit max 1000 request per 15 minutes on user endpoints\nexport const defaultUserRateLimiting = {\n windowMs: 15 * 60 * 1000, // 15 minutes\n max: 1000,\n};\n\n/**\n * Coordinates the application configuration\n */\nclass Config implements AppConfig {\n public user_agent: string | undefined;\n public uplinks: any;\n public packages: PackageList;\n public users: any;\n public auth: AuthConf;\n public server_id: string;\n // @deprecated use configPath instead\n public config_path: string;\n public configPath: string;\n public storage: string | void;\n\n public plugins: string | void | null;\n public security: Security;\n public serverSettings: ServerSettingsConf;\n // @ts-ignore\n public secret: string;\n public flags: FlagsConfig;\n public userRateLimit: RateLimit;\n public constructor(config: ConfigYaml & { config_path: string }) {\n const self = this;\n this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;\n if (!config.configPath) {\n throw new Error('config_path is required');\n }\n this.config_path = config.config_path ?? (config.configPath as string);\n this.configPath = config.configPath;\n debug('config path: %s', this.configPath);\n this.plugins = config.plugins;\n this.security = _.merge(defaultSecurity, config.security);\n this.serverSettings = serverSettings;\n this.flags = {\n searchRemote: config.flags?.searchRemote ?? true,\n };\n this.user_agent = config.user_agent;\n\n for (const configProp in config) {\n if (self[configProp] == null) {\n self[configProp] = config[configProp];\n }\n }\n\n if (typeof this.user_agent === 'undefined') {\n // by default user agent is hidden\n debug('set default user agent');\n this.user_agent = getUserAgent(false);\n }\n\n this.userRateLimit = { ...defaultUserRateLimiting, ...config?.userRateLimit };\n\n // some weird shell scripts are valid yaml files parsed as string\n assert(_.isObject(config), APP_ERROR.CONFIG_NOT_VALID);\n\n // sanity check for strategic config properties\n strategicConfigProps.forEach(function (x): void {\n if (self[x] == null) {\n self[x] = {};\n }\n\n assert(isObject(self[x]), `CONFIG: bad \"${x}\" value (object expected)`);\n });\n\n this.uplinks = sanityCheckUplinksProps(uplinkSanityCheck(this.uplinks));\n this.packages = normalisePackageAccess(self.packages);\n\n // loading these from ENV if aren't in config\n allowedEnvConfig.forEach((envConf): void => {\n if (!(envConf in self)) {\n self[envConf] = process.env[envConf] || process.env[envConf.toUpperCase()];\n }\n });\n\n // unique identifier of self server (or a cluster), used to avoid loops\n // @ts-ignore\n if (!this.server_id) {\n this.server_id = generateRandomHexString(6);\n }\n }\n\n /**\n * Check for package spec\n */\n public getMatchedPackagesSpec(pkgName: string): PackageAccess | void {\n // TODO: remove this method and replace by library utils\n return getMatchedPackagesSpec(pkgName, this.packages);\n }\n\n /**\n * Store or create whether receive a secret key\n */\n public checkSecretKey(secret?: string): string {\n debug('check secret key');\n if (_.isString(secret) && _.isEmpty(secret) === false) {\n this.secret = secret;\n debug('reusing previous key');\n return secret;\n }\n // it generates a secret key\n // FUTURE: this might be an external secret key, perhaps within config file?\n debug('generate a new key');\n this.secret = generateRandomSecretKey();\n return this.secret;\n }\n}\n\nexport { Config };\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AAYA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAuE;AAEvE,M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,OAAO,CAACC,GAAG,CAAC4B,OAAO,CAACC,WAAW,EAAE,CAAC;MAC5E;IACF,CAAC,CAAC;;IAEF;IACA;IACA,IAAI,CAAC,IAAI,CAACC,SAAS,EAAE;MACnB,IAAI,CAACA,SAAS,GAAG,IAAAC,8BAAuB,EAAC,CAAC,CAAC;IAC7C;EACF;;EAEA;AACF;AACA;EACSC,sBAAsB,CAACC,OAAe,EAAwB;IACnE;IACA,OAAO,IAAAD,6BAAsB,EAACC,OAAO,EAAE,IAAI,CAACP,QAAQ,CAAC;EACvD;;EAEA;AACF;AACA;EACSQ,cAAc,CAACC,MAAe,EAAU;IAC7C/C,KAAK,CAAC,kBAAkB,CAAC;IACzB,IAAImB,eAAC,CAAC6B,QAAQ,CAACD,MAAM,CAAC,IAAI5B,eAAC,CAAC8B,OAAO,CAACF,MAAM,CAAC,KAAK,KAAK,EAAE;MACrD,IAAI,CAACA,MAAM,GAAGA,MAAM;MACpB/C,KAAK,CAAC,sBAAsB,CAAC;MAC7B,OAAO+C,MAAM;IACf;IACA;IACA;IACA/C,KAAK,CAAC,oBAAoB,CAAC;IAC3B,IAAI,CAAC+C,MAAM,GAAG,IAAAG,8BAAuB,GAAE;IACvC,OAAO,IAAI,CAACH,MAAM;EACpB;AACF;AAAC"}
1
+ {"version":3,"file":"config.js","names":["strategicConfigProps","allowedEnvConfig","debug","buildDebug","WEB_TITLE","defaultUserRateLimiting","windowMs","max","Config","constructor","config","configOptions","forceEnhancedLegacySignature","self","storage","process","env","VERDACCIO_STORAGE_PATH","configPath","config_path","self_path","Error","plugins","security","_","merge","defaultSecurity","serverSettings","flags","searchRemote","user_agent","configProp","getUserAgent","userRateLimit","assert","isObject","APP_ERROR","CONFIG_NOT_VALID","forEach","x","uplinks","sanityCheckUplinksProps","uplinkSanityCheck","packages","normalisePackageAccess","envConf","toUpperCase","server_id","generateRandomHexString","getConfigPath","getMatchedPackagesSpec","pkgName","checkSecretKey","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 };\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;AACA;AACA;AAEA;AACA;AAYA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAuE;AAEvE,MAAMA,oBAAoB,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC;AACpD,MAAMC,gBAAgB,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,UAAU,CAAC;AAClE,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,kBAAkB,CAAC;AAErC,MAAMC,SAAS,GAAG,WAAW;;AAEpC;AAAA;AACO,MAAMC,uBAAuB,GAAG;EACrCC,QAAQ,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;EAAE;EAC1BC,GAAG,EAAE;AACP,CAAC;;AAED;AACA;AACA;AAFA;AAGA,MAAMC,MAAM,CAAsB;EAQhC;AACF;AACA;;EAOE;;EAKOC,WAAW,CAChBC,MAA4C,EAC5CC,aAAa,GAAG;IAAEC,4BAA4B,EAAE;EAAK,CAAC,EACtD;IAAA;IACA,MAAMC,IAAI,GAAG,IAAI;IACjB,IAAI,CAACF,aAAa,GAAGA,aAAa;IAClC,IAAI,CAACG,OAAO,GAAGC,OAAO,CAACC,GAAG,CAACC,sBAAsB,IAAIP,MAAM,CAACI,OAAO;IACnE,IAAI,CAACJ,MAAM,CAACQ,UAAU,EAAE;MAAA;MACtB;MACA;MACAR,MAAM,CAACQ,UAAU,0BAAGR,MAAM,CAACS,WAAW,qEAAIT,MAA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AACD,MAAM,CAAC,KAAK,KAAK,EAAE;MAC7D,IAAI,CAACA,MAAM,GAAGA,MAAM;MACpBnD,KAAK,CAAC,sBAAsB,CAAC;MAC7B,OAAOmD,MAAM;IACf;IACA;IACA;IACAnD,KAAK,CAAC,oBAAoB,CAAC;IAC3B;IACA,IAAI,IAAI,CAACS,aAAa,CAACC,4BAA4B,EAAE;MACnD,IAAI,CAACyC,MAAM,GAAG,IAAAE,8BAAuB,GAAE;IACzC,CAAC,MAAM;MACL,IAAI,CAACF,MAAM,GACT,IAAI,CAAC9B,QAAQ,CAACiC,uBAAuB,KAAK,IAAI,GAC1C,IAAAD,8BAAuB,GAAE,GACzB,IAAAP,8BAAuB,EAAC,EAAE,CAAC;MACjC;MACA;MACA;MACA,IAAI,IAAI,CAACzB,QAAQ,CAACiC,uBAAuB,KAAK,KAAK,EAAE;QACnDC,kBAAY,CAACC,IAAI,CAACC,mBAAK,CAACC,SAAS,CAAC;MACpC;IACF;IAEA1D,KAAK,CAAC,+BAA+B,kBAAE,IAAI,CAACmD,MAAM,iDAAX,aAAaQ,MAAM,CAAC;IAC3D,OAAO,IAAI,CAACR,MAAM;EACpB;AACF;AAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/config",
3
- "version": "6.0.0-6-next.62",
3
+ "version": "6.0.0-6-next.63",
4
4
  "description": "logger",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -29,8 +29,8 @@
29
29
  "node": ">=12"
30
30
  },
31
31
  "dependencies": {
32
- "@verdaccio/core": "6.0.0-6-next.62",
33
- "@verdaccio/utils": "6.0.0-6-next.30",
32
+ "@verdaccio/core": "6.0.0-6-next.63",
33
+ "@verdaccio/utils": "6.0.0-6-next.31",
34
34
  "debug": "4.3.4",
35
35
  "js-yaml": "4.1.0",
36
36
  "lodash": "4.17.21",
@@ -28,7 +28,6 @@ const debug = buildDebug('verdaccio:config');
28
28
  * @return {String} the config file path
29
29
  */
30
30
  function findConfigFile(configPath?: string): string {
31
- // console.log(process.env);
32
31
  if (typeof configPath !== 'undefined') {
33
32
  return path.resolve(configPath);
34
33
  }
package/src/config.ts CHANGED
@@ -2,7 +2,8 @@ import assert from 'assert';
2
2
  import buildDebug from 'debug';
3
3
  import _ from 'lodash';
4
4
 
5
- import { APP_ERROR } from '@verdaccio/core';
5
+ import { APP_ERROR, warningUtils } from '@verdaccio/core';
6
+ import { Codes } from '@verdaccio/core/build/warning-utils';
6
7
  import {
7
8
  Config as AppConfig,
8
9
  AuthConf,
@@ -45,9 +46,11 @@ class Config implements AppConfig {
45
46
  public users: any;
46
47
  public auth: AuthConf;
47
48
  public server_id: string;
48
- // @deprecated use configPath instead
49
- public config_path: string;
50
49
  public configPath: string;
50
+ /**
51
+ * @deprecated use configPath or config.getConfigPath();
52
+ */
53
+ public self_path: string;
51
54
  public storage: string | void;
52
55
 
53
56
  public plugins: string | void | null;
@@ -57,14 +60,24 @@ class Config implements AppConfig {
57
60
  public secret: string;
58
61
  public flags: FlagsConfig;
59
62
  public userRateLimit: RateLimit;
60
- public constructor(config: ConfigYaml & { config_path: string }) {
63
+ private configOptions: { forceEnhancedLegacySignature: boolean };
64
+ public constructor(
65
+ config: ConfigYaml & { config_path: string },
66
+ configOptions = { forceEnhancedLegacySignature: true }
67
+ ) {
61
68
  const self = this;
69
+ this.configOptions = configOptions;
62
70
  this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;
63
71
  if (!config.configPath) {
64
- throw new Error('config_path is required');
72
+ // backport self_path for previous to version 6
73
+ // @ts-expect-error
74
+ config.configPath = config.config_path ?? config.self_path;
75
+ if (!config.configPath) {
76
+ throw new Error('configPath property is required');
77
+ }
65
78
  }
66
- this.config_path = config.config_path ?? (config.configPath as string);
67
79
  this.configPath = config.configPath;
80
+ this.self_path = this.configPath;
68
81
  debug('config path: %s', this.configPath);
69
82
  this.plugins = config.plugins;
70
83
  this.security = _.merge(defaultSecurity, config.security);
@@ -117,6 +130,10 @@ class Config implements AppConfig {
117
130
  }
118
131
  }
119
132
 
133
+ public getConfigPath() {
134
+ return this.configPath;
135
+ }
136
+
120
137
  /**
121
138
  * Check for package spec
122
139
  */
@@ -127,18 +144,35 @@ class Config implements AppConfig {
127
144
 
128
145
  /**
129
146
  * Store or create whether receive a secret key
147
+ * @secret external secret key
130
148
  */
131
149
  public checkSecretKey(secret?: string): string {
132
150
  debug('check secret key');
133
- if (_.isString(secret) && _.isEmpty(secret) === false) {
151
+ if (typeof secret === 'string' && _.isEmpty(secret) === false) {
134
152
  this.secret = secret;
135
153
  debug('reusing previous key');
136
154
  return secret;
137
155
  }
138
- // it generates a secret key
156
+ // generate a new a secret key
139
157
  // FUTURE: this might be an external secret key, perhaps within config file?
140
158
  debug('generate a new key');
141
- this.secret = generateRandomSecretKey();
159
+ //
160
+ if (this.configOptions.forceEnhancedLegacySignature) {
161
+ this.secret = generateRandomSecretKey();
162
+ } else {
163
+ this.secret =
164
+ this.security.enhancedLegacySignature === true
165
+ ? generateRandomSecretKey()
166
+ : generateRandomHexString(32);
167
+ // set this to false allow use old token signature and is not recommended
168
+ // only use for migration reasons, major release will remove this property and
169
+ // set it by default
170
+ if (this.security.enhancedLegacySignature === false) {
171
+ warningUtils.emit(Codes.VERWAR005);
172
+ }
173
+ }
174
+
175
+ debug('generated a new secret key %s', this.secret?.length);
142
176
  return this.secret;
143
177
  }
144
178
  }
package/tsconfig.json CHANGED
@@ -9,6 +9,9 @@
9
9
  "references": [
10
10
  {
11
11
  "path": "../utils"
12
+ },
13
+ {
14
+ "path": "../core/core"
12
15
  }
13
16
  ]
14
17
  }