@verdaccio/config 6.0.0-6-next.8 → 6.0.0-6-next.12
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 +44 -0
- package/build/config-path.js +6 -6
- package/build/config-path.js.map +1 -1
- package/build/config-utils.js +1 -1
- package/build/config.d.ts +1 -1
- package/build/config.js +10 -36
- package/build/config.js.map +1 -1
- package/build/package-access.js +6 -11
- package/build/package-access.js.map +1 -1
- package/build/parse.js +2 -2
- package/build/parse.js.map +1 -1
- package/build/token.js +1 -1
- package/build/uplinks.js +5 -5
- package/build/uplinks.js.map +1 -1
- package/build/user.js +1 -1
- package/package.json +6 -6
- package/src/config-path.ts +5 -4
- package/src/config.ts +9 -9
- package/src/package-access.ts +4 -2
- package/src/parse.ts +2 -1
- package/src/uplinks.ts +3 -2
- package/test/config.path.spec.ts +1 -0
- package/test/config.spec.ts +3 -3
- package/test/package-access.spec.ts +1 -1
- package/test/token.spec.ts +1 -1
- package/test/uplinks.spec.ts +1 -1
- package/test/utils.spec.ts +1 -1
- package/tsconfig.json +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @verdaccio/config
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [a828271d]
|
|
8
|
+
- Updated dependencies [24b9be02]
|
|
9
|
+
- Updated dependencies [b13a3fef]
|
|
10
|
+
- @verdaccio/utils@6.0.0-6-next.10
|
|
11
|
+
- @verdaccio/core@6.0.0-6-next.4
|
|
12
|
+
|
|
13
|
+
## 6.0.0-6-next.11
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [f86c31ed]
|
|
18
|
+
- @verdaccio/utils@6.0.0-6-next.9
|
|
19
|
+
|
|
20
|
+
## 6.0.0-6-next.10
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [6c1eb021]
|
|
25
|
+
- @verdaccio/core@6.0.0-6-next.3
|
|
26
|
+
- @verdaccio/utils@6.0.0-6-next.8
|
|
27
|
+
|
|
28
|
+
## 6.0.0-6-next.9
|
|
29
|
+
|
|
30
|
+
### Major Changes
|
|
31
|
+
|
|
32
|
+
- 794af76c: Remove Node 12 support
|
|
33
|
+
|
|
34
|
+
- We need move to the new `undici` and does not support Node.js 12
|
|
35
|
+
|
|
36
|
+
### Minor Changes
|
|
37
|
+
|
|
38
|
+
- 154b2ecd: refactor: remove @verdaccio/commons-api in favor @verdaccio/core and remove duplications
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [794af76c]
|
|
43
|
+
- Updated dependencies [154b2ecd]
|
|
44
|
+
- @verdaccio/core@6.0.0-6-next.2
|
|
45
|
+
- @verdaccio/utils@6.0.0-6-next.7
|
|
46
|
+
|
|
3
47
|
## 6.0.0-6-next.8
|
|
4
48
|
|
|
5
49
|
### Major Changes
|
package/build/config-path.js
CHANGED
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.readDefaultConfig = readDefaultConfig;
|
|
7
6
|
exports.findConfigFile = findConfigFile;
|
|
7
|
+
exports.readDefaultConfig = readDefaultConfig;
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
12
12
|
|
|
13
13
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _path = _interopRequireDefault(require("path"));
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _core = require("@verdaccio/core");
|
|
18
18
|
|
|
19
19
|
var _configUtils = require("./config-utils");
|
|
20
20
|
|
|
@@ -81,7 +81,7 @@ function readDefaultConfig() {
|
|
|
81
81
|
} // @ts-ignore
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
return _fs.default.readFileSync(pathDefaultConf,
|
|
84
|
+
return _fs.default.readFileSync(pathDefaultConf, _core.CHARACTER_ENCODING.UTF8);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
function createConfigFolder(configLocation) {
|
package/build/config-path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config-path.ts"],"names":["CONFIG_FILE","XDG","WIN","WIN32","pkgJSON","name","debug","findConfigFile","configPath","path","resolve","configPaths","getConfigPaths","length","_","isEmpty","Error","primaryConf","find","configLocation","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","replace","listPaths","getXDGDirectory","getWindowsDirectory","getRelativeDefaultDirectory","getOldDirectory","reduce","acc","currentValue","push","xDGConfigPath","XDG_CONFIG_HOME","platform","APPDATA"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;AAEA,MAAMA,WAAW,GAAG,aAApB;AACA,MAAMC,GAAG,GAAG,KAAZ;AACA,MAAMC,GAAG,GAAG,KAAZ;AACA,MAAMC,KAAK,GAAG,OAAd,C,CACA;;AACA,MAAMC,OAAO,GAAG;AACdC,EAAAA,IAAI,EAAE;AADQ,CAAhB;AASA,MAAMC,KAAK,GAAG,oBAAW,kBAAX,CAAd;AAEA;AACA;AACA;AACA;;AACA,SAASC,cAAT,CAAwBC,UAAxB,EAAqD;AACnD;AACA,MAAI,OAAOA,UAAP,KAAsB,WAA1B,EAAuC;AACrC,WAAOC,cAAKC,OAAL,CAAaF,UAAb,C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L;AACA,WAAO;AACLnD,MAAAA,IAAI,EAAEA,cAAKC,OAAL,CAAaD,cAAKoC,IAAL,CAAUH,OAAO,CAACC,GAAR,CAAYiB,OAAtB,EAA+BxD,OAAO,CAACC,IAAvC,EAA6CL,WAA7C,CAAb,CADD;AAELwC,MAAAA,IAAI,EAAEtC;AAFD,KAAP;AAID;AACF,CARD;AAUA;AACA;AACA;AACA;AACA;;;AACA,MAAMiD,2BAA2B,GAAG,MAAsB;AACxD,SAAO;AACL1C,IAAAA,IAAI,EAAEA,cAAKC,OAAL,CAAaD,cAAKoC,IAAL,CAAU,GAAV,EAAezC,OAAO,CAACC,IAAvB,EAA6BL,WAA7B,CAAb,CADD;AAELwC,IAAAA,IAAI,EAAE;AAFD,GAAP;AAID,CALD;AAOA;AACA;AACA;AACA;;;AACA,MAAMY,eAAe,GAAG,MAAsB;AAC5C,SAAO;AACL3C,IAAAA,IAAI,EAAEA,cAAKC,OAAL,CAAaD,cAAKoC,IAAL,CAAU,GAAV,EAAe7C,WAAf,CAAb,CADD;AAELwC,IAAAA,IAAI,EAAE;AAFD,GAAP;AAID,CALD","sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport _ from 'lodash';\nimport buildDebug from 'debug';\n\nimport { CHARACTER_ENCODING } from '@verdaccio/commons-api';\nimport { folderExists, fileExists } 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"],"file":"config-path.js"}
|
|
1
|
+
{"version":3,"sources":["../src/config-path.ts"],"names":["CONFIG_FILE","XDG","WIN","WIN32","pkgJSON","name","debug","findConfigFile","configPath","path","resolve","configPaths","getConfigPaths","length","_","isEmpty","Error","primaryConf","find","configLocation","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","replace","listPaths","getXDGDirectory","getWindowsDirectory","getRelativeDefaultDirectory","getOldDirectory","reduce","acc","currentValue","push","xDGConfigPath","XDG_CONFIG_HOME","platform","APPDATA"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;;;AAEA,MAAMA,WAAW,GAAG,aAApB;AACA,MAAMC,GAAG,GAAG,KAAZ;AACA,MAAMC,GAAG,GAAG,KAAZ;AACA,MAAMC,KAAK,GAAG,OAAd,C,CACA;;AACA,MAAMC,OAAO,GAAG;AACdC,EAAAA,IAAI,EAAE;AADQ,CAAhB;AASA,MAAMC,KAAK,GAAG,oBAAW,kBAAX,CAAd;AAEA;AACA;AACA;AACA;;AACA,SAASC,cAAT,CAAwBC,UAAxB,EAAqD;AACnD;AACA,MAAI,OAAOA,UAAP,KAAsB,WAA1B,EAAuC;AACrC,WAAOC,cAAKC,OAAL,CAAaF,UAAb,CAAP;AACD;;AAED,QAAMG,WAA6B,GAAGC,cAAc,EAApD;AACAN,EAAAA,KAAK,CAAC,4BAAD,EAA+BK,WAAW,CAACE,MAA3C,CAAL;;AACA,MAAIC,gBAAEC,OAAF,CAAUJ,WAAV,CAAJ,EAA4B;AAC1B;AACA,UAAM,IAAIK,KAAJ,CAAU,yCAAV,CAAN;AACD,GAXkD,CAanD;;;AACA,QAAMC,WAAkC,GAAGH,gBAAEI,IAAF,CAAOP,WAAP,EAAqBQ,cAAD,IAC7D,6BAAWA,cAAc,CAACV,IAA1B,CADyC,CAA3C;;AAIA,MAAI,OAAOQ,WAAP,KAAuB,WAA3B,EAAwC;AACtCX,IAAAA,KAAK,CAAC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IAAAA,IAAI,EAAE;AAFD,GAAP;AAID,CALD;AAOA;AACA;AACA;AACA;;;AACA,MAAMY,eAAe,GAAG,MAAsB;AAC5C,SAAO;AACL3C,IAAAA,IAAI,EAAEA,cAAKC,OAAL,CAAaD,cAAKoC,IAAL,CAAU,GAAV,EAAe7C,WAAf,CAAb,CADD;AAELwC,IAAAA,IAAI,EAAE;AAFD,GAAP;AAID,CALD","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"],"file":"config-path.js"}
|
package/build/config-utils.js
CHANGED
package/build/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Config as AppConfig, AuthConf, ConfigRuntime, PackageAccess, PackageList, Security, ServerSettingsConf } from '@verdaccio/types';
|
|
2
2
|
export declare const WEB_TITLE = "Verdaccio";
|
|
3
3
|
/**
|
|
4
4
|
* Coordinates the application configuration
|
package/build/config.js
CHANGED
|
@@ -3,33 +3,31 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.WEB_TITLE = exports.Config = void 0;
|
|
7
7
|
|
|
8
8
|
var _assert = _interopRequireDefault(require("assert"));
|
|
9
9
|
|
|
10
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
11
|
+
|
|
10
12
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
13
|
|
|
12
|
-
var
|
|
14
|
+
var _core = require("@verdaccio/core");
|
|
13
15
|
|
|
14
16
|
var _utils = require("@verdaccio/utils");
|
|
15
17
|
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
var _token = require("./token");
|
|
18
|
+
var _agent = require("./agent");
|
|
19
19
|
|
|
20
20
|
var _packageAccess = require("./package-access");
|
|
21
21
|
|
|
22
|
-
var _uplinks = require("./uplinks");
|
|
23
|
-
|
|
24
22
|
var _security = require("./security");
|
|
25
23
|
|
|
26
|
-
var _agent = require("./agent");
|
|
27
|
-
|
|
28
24
|
var _serverSettings = _interopRequireDefault(require("./serverSettings"));
|
|
29
25
|
|
|
30
|
-
|
|
26
|
+
var _token = require("./token");
|
|
31
27
|
|
|
32
|
-
|
|
28
|
+
var _uplinks = require("./uplinks");
|
|
29
|
+
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
31
|
|
|
34
32
|
const strategicConfigProps = ['uplinks', 'packages'];
|
|
35
33
|
const allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];
|
|
@@ -44,30 +42,6 @@ exports.WEB_TITLE = WEB_TITLE;
|
|
|
44
42
|
class Config {
|
|
45
43
|
// @ts-ignore
|
|
46
44
|
constructor(config) {
|
|
47
|
-
_defineProperty(this, "user_agent", void 0);
|
|
48
|
-
|
|
49
|
-
_defineProperty(this, "uplinks", void 0);
|
|
50
|
-
|
|
51
|
-
_defineProperty(this, "packages", void 0);
|
|
52
|
-
|
|
53
|
-
_defineProperty(this, "users", void 0);
|
|
54
|
-
|
|
55
|
-
_defineProperty(this, "auth", void 0);
|
|
56
|
-
|
|
57
|
-
_defineProperty(this, "server_id", void 0);
|
|
58
|
-
|
|
59
|
-
_defineProperty(this, "config_path", void 0);
|
|
60
|
-
|
|
61
|
-
_defineProperty(this, "storage", void 0);
|
|
62
|
-
|
|
63
|
-
_defineProperty(this, "plugins", void 0);
|
|
64
|
-
|
|
65
|
-
_defineProperty(this, "security", void 0);
|
|
66
|
-
|
|
67
|
-
_defineProperty(this, "serverSettings", void 0);
|
|
68
|
-
|
|
69
|
-
_defineProperty(this, "secret", void 0);
|
|
70
|
-
|
|
71
45
|
const self = this;
|
|
72
46
|
this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;
|
|
73
47
|
this.config_path = config.config_path;
|
|
@@ -87,7 +61,7 @@ class Config {
|
|
|
87
61
|
} // some weird shell scripts are valid yaml files parsed as string
|
|
88
62
|
|
|
89
63
|
|
|
90
|
-
(0, _assert.default)(_lodash.default.isObject(config),
|
|
64
|
+
(0, _assert.default)(_lodash.default.isObject(config), _core.APP_ERROR.CONFIG_NOT_VALID); // sanity check for strategic config properties
|
|
91
65
|
|
|
92
66
|
strategicConfigProps.forEach(function (x) {
|
|
93
67
|
if (self[x] == null) {
|
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config.ts"],"names":["strategicConfigProps","allowedEnvConfig","debug","WEB_TITLE","Config","constructor","config","self","storage","process","env","VERDACCIO_STORAGE_PATH","config_path","plugins","security","_","merge","defaultSecurity","serverSettings","configProp","isNil","user_agent","isObject","APP_ERROR","CONFIG_NOT_VALID","forEach","x","uplinks","packages","envConf","toUpperCase","server_id","getMatchedPackagesSpec","pkgName","checkSecretKey","secret","isString","isEmpty"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;
|
|
1
|
+
{"version":3,"sources":["../src/config.ts"],"names":["strategicConfigProps","allowedEnvConfig","debug","WEB_TITLE","Config","constructor","config","self","storage","process","env","VERDACCIO_STORAGE_PATH","config_path","plugins","security","_","merge","defaultSecurity","serverSettings","configProp","isNil","user_agent","isObject","APP_ERROR","CONFIG_NOT_VALID","forEach","x","uplinks","packages","envConf","toUpperCase","server_id","getMatchedPackagesSpec","pkgName","checkSecretKey","secret","isString","isEmpty"],"mappings":";;;;;;;AAA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CAAd;AACA,WAAO,KAAKA,MAAZ;AACD;;AAtF+B","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 ConfigRuntime,\n PackageAccess,\n PackageList,\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/**\n * Coordinates the application configuration\n */\nclass Config implements AppConfig {\n public user_agent: string;\n public uplinks: any;\n public packages: PackageList;\n public users: any;\n public auth: AuthConf;\n public server_id: string;\n public config_path: string;\n public storage: string | void;\n public plugins: string | void;\n public security: Security;\n public serverSettings: ServerSettingsConf;\n // @ts-ignore\n public secret: string;\n\n public constructor(config: ConfigRuntime) {\n const self = this;\n this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;\n this.config_path = config.config_path;\n this.plugins = config.plugins;\n this.security = _.merge(defaultSecurity, config.security);\n this.serverSettings = serverSettings;\n\n for (const configProp in config) {\n if (self[configProp] == null) {\n self[configProp] = config[configProp];\n }\n }\n\n // @ts-ignore\n if (_.isNil(this.user_agent)) {\n this.user_agent = getUserAgent();\n }\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"],"file":"config.js"}
|
package/build/package-access.js
CHANGED
|
@@ -3,24 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.ROLES = exports.PACKAGE_ACCESS = void 0;
|
|
7
7
|
exports.normalisePackageAccess = normalisePackageAccess;
|
|
8
|
-
exports.
|
|
8
|
+
exports.normalizeUserList = normalizeUserList;
|
|
9
9
|
|
|
10
10
|
var _assert = _interopRequireDefault(require("assert"));
|
|
11
11
|
|
|
12
12
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _core = require("@verdaccio/core");
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
21
|
-
|
|
22
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
-
|
|
24
18
|
const ROLES = {
|
|
25
19
|
$ALL: '$all',
|
|
26
20
|
ALL: 'all',
|
|
@@ -51,14 +45,15 @@ function normalizeUserList(groupsList) {
|
|
|
51
45
|
} else if (Array.isArray(groupsList)) {
|
|
52
46
|
result.push(groupsList);
|
|
53
47
|
} else {
|
|
54
|
-
throw
|
|
48
|
+
throw _core.errorUtils.getInternalError('CONFIG: bad package acl (array or string expected): ' + JSON.stringify(groupsList));
|
|
55
49
|
}
|
|
56
50
|
|
|
57
51
|
return _lodash.default.flatten(result);
|
|
58
52
|
}
|
|
59
53
|
|
|
60
54
|
function normalisePackageAccess(packages) {
|
|
61
|
-
const normalizedPkgs =
|
|
55
|
+
const normalizedPkgs = { ...packages
|
|
56
|
+
};
|
|
62
57
|
|
|
63
58
|
if (_lodash.default.isNil(normalizedPkgs['**'])) {
|
|
64
59
|
normalizedPkgs['**'] = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/package-access.ts"],"names":["ROLES","$ALL","ALL","$AUTH","$ANONYMOUS","DEPRECATED_ALL","DEPRECATED_AUTH","DEPRECATED_ANONYMOUS","PACKAGE_ACCESS","SCOPE","normalizeUserList","groupsList","result","_","isNil","isString","groupsArray","split","push","Array","isArray","
|
|
1
|
+
{"version":3,"sources":["../src/package-access.ts"],"names":["ROLES","$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","isUndefined"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;;;;AAOO,MAAMA,KAAK,GAAG;AACnBC,EAAAA,IAAI,EAAE,MADa;AAEnBC,EAAAA,GAAG,EAAE,KAFc;AAGnBC,EAAAA,KAAK,EAAE,gBAHY;AAInBC,EAAAA,UAAU,EAAE,YAJO;AAKnBC,EAAAA,cAAc,EAAE,MALG;AAMnBC,EAAAA,eAAe,EAAE,gBANE;AAOnBC,EAAAA,oBAAoB,EAAE;AAPH,CAAd;;AAUA,MAAMC,cAAc,GAAG;AAC5BC,EAAAA,KAAK,EAAE,MADqB;AAE5BP,EAAAA,GAAG,EAAE;AAFuB,CAAvB;;;AAKA,SAASQ,iBAAT,CAA2BC,UAA3B,EAAiD;AACtD,QAAMC,MAAa,GAAG,EAAtB;;AACA,MAAIC,gBAAEC,KAAF,CAAQH,UAAR,CAAJ,EAAyB;AACvB,WAAOC,MAAP;AACD,GAJqD,CAMtD;;;AACA,MAAIC,gBAAEE,QAAF,CAAWJ,UAAX,CAAJ,EAA4B;AAC1B,UAAMK,WAAW,GAAGL,UAAU,CAACM,KAAX,CAAiB,KAAjB,CAApB;AAEAL,IAAAA,MAAM,CAACM,IAAP,CAAYF,WAAZ;AACD,GAJD,MAIO,IAAIG,KAAK,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AApB,GAA4BtB,iBAAiB,CAAC4B,aAAa,CAACN,KAAf,CAA7C,CAPuD,CAQvD;;AACAJ,MAAAA,cAAc,CAACK,GAAD,CAAd,CAAoBF,SAApB,GAAgClB,gBAAE4B,WAAF,CAAcH,aAAa,CAACP,SAA5B,IAC5B,KAD4B,GAE5BrB,iBAAiB,CAAC4B,aAAa,CAACP,SAAf,CAFrB;AAGD;AACF;;AAED,SAAOH,cAAP;AACD","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\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\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"],"file":"package-access.js"}
|
package/build/parse.js
CHANGED
|
@@ -9,7 +9,7 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
9
9
|
|
|
10
10
|
var _jsYaml = _interopRequireDefault(require("js-yaml"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _core = require("@verdaccio/core");
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
@@ -38,7 +38,7 @@ function parseConfigFile(configPath) {
|
|
|
38
38
|
});
|
|
39
39
|
} catch (e) {
|
|
40
40
|
if (e.code !== 'MODULE_NOT_FOUND') {
|
|
41
|
-
e.message =
|
|
41
|
+
e.message = _core.APP_ERROR.CONFIG_NOT_VALID;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
throw e;
|
package/build/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/parse.ts"],"names":["parseConfigFile","configPath","test","yamlConfig","YAML","safeLoad","fs","readFileSync","Object","assign","config_path","jsonConfig","require","e","code","message","APP_ERROR","CONFIG_NOT_VALID"],"mappings":";;;;;;;AAAA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["../src/parse.ts"],"names":["parseConfigFile","configPath","test","yamlConfig","YAML","safeLoad","fs","readFileSync","Object","assign","config_path","jsonConfig","require","e","code","message","APP_ERROR","CONFIG_NOT_VALID"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;AAGA;AACA;AACA;AACA;AACO,SAASA,eAAT,CAAyBC,UAAzB,EAA4D;AACjE,MAAI;AACF,QAAI,YAAYC,IAAZ,CAAiBD,UAAjB,CAAJ,EAAkC;AAChC,YAAME,UAAU,GAAGC,gBAAKC,QAAL,CAAcC,YAAGC,YAAH,CAAgBN,UAAhB,EAA4B,MAA5B,CAAd,CAAnB;;AACA,aAAOO,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBN,UAAlB,EAA8B;AACnCF,QAAAA,UADmC;AAEnC;AACAS,QAAAA,WAAW,EAAET;AAHsB,OAA9B,CAAP;AAKD;;AAED,UAAMU,UAAU,GAAGC,OAAO,CAACX,UAAD,CAA1B;;AACA,WAAOO,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBE,UAAlB,EAA8B;AACnCV,MAAAA,UADmC;AAEnC;AACAS,MAAAA,WAAW,EAAET;AAHsB,KAA9B,CAAP;AAKD,GAhBD,CAgBE,OAAOY,CAAP,EAAe;AACf,QAAIA,CAAC,CAACC,IAAF,KAAW,kBAAf,EAAmC;AACjCD,MAAAA,CAAC,CAACE,OAAF,GAAYC,gBAAUC,gBAAtB;AACD;;AAED,UAAMJ,CAAN;AACD;AACF","sourcesContent":["import fs from 'fs';\nimport YAML from 'js-yaml';\n\nimport { APP_ERROR } from '@verdaccio/core';\nimport { ConfigRuntime, ConfigYaml } from '@verdaccio/types';\n\n/**\n * Parse a config file from yaml to JSON.\n * @param configPath the absolute path of the configuration file\n */\nexport function parseConfigFile(configPath: string): ConfigRuntime {\n try {\n if (/\\.ya?ml$/i.test(configPath)) {\n const yamlConfig = YAML.safeLoad(fs.readFileSync(configPath, 'utf8')) as ConfigYaml;\n return Object.assign({}, yamlConfig, {\n configPath,\n // @deprecated use configPath instead\n config_path: configPath,\n });\n }\n\n const jsonConfig = require(configPath) as ConfigYaml;\n return Object.assign({}, jsonConfig, {\n configPath,\n // @deprecated use configPath instead\n config_path: configPath,\n });\n } catch (e: any) {\n if (e.code !== 'MODULE_NOT_FOUND') {\n e.message = APP_ERROR.CONFIG_NOT_VALID;\n }\n\n throw e;\n }\n}\n"],"file":"parse.js"}
|
package/build/token.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.generateRandomSecretKey = generateRandomSecretKey;
|
|
7
6
|
exports.TOKEN_VALID_LENGTH = void 0;
|
|
7
|
+
exports.generateRandomSecretKey = generateRandomSecretKey;
|
|
8
8
|
|
|
9
9
|
var _crypto = require("crypto");
|
|
10
10
|
|
package/build/uplinks.js
CHANGED
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.sanityCheckUplinksProps = sanityCheckUplinksProps;
|
|
6
|
+
exports.DEFAULT_UPLINK = exports.DEFAULT_REGISTRY = void 0;
|
|
8
7
|
exports.hasProxyTo = hasProxyTo;
|
|
9
8
|
exports.sanityCheckNames = sanityCheckNames;
|
|
10
|
-
exports.
|
|
9
|
+
exports.sanityCheckUplinksProps = sanityCheckUplinksProps;
|
|
10
|
+
exports.uplinkSanityCheck = uplinkSanityCheck;
|
|
11
11
|
|
|
12
12
|
var _assert = _interopRequireDefault(require("assert"));
|
|
13
13
|
|
|
14
|
-
var _utils = require("@verdaccio/utils");
|
|
15
|
-
|
|
16
14
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
17
15
|
|
|
16
|
+
var _utils = require("@verdaccio/utils");
|
|
17
|
+
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
20
|
const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
package/build/uplinks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/uplinks.ts"],"names":["DEFAULT_REGISTRY","DEFAULT_UPLINK","BLACKLIST","all","anonymous","undefined","owner","none","uplinkSanityCheck","uplinks","users","newUplinks","_","clone","newUsers","uplink","Object","prototype","hasOwnProperty","call","isNil","cache","sanityCheckNames","sanityCheckUplinksProps","configUpLinks","url","isString","replace","hasProxyTo","pkg","upLink","packages","matchedPkg","proxyList","proxy","some","curr","item","match"],"mappings":";;;;;;;;;;;AAAA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["../src/uplinks.ts"],"names":["DEFAULT_REGISTRY","DEFAULT_UPLINK","BLACKLIST","all","anonymous","undefined","owner","none","uplinkSanityCheck","uplinks","users","newUplinks","_","clone","newUsers","uplink","Object","prototype","hasOwnProperty","call","isNil","cache","sanityCheckNames","sanityCheckUplinksProps","configUpLinks","url","isString","replace","hasProxyTo","pkg","upLink","packages","matchedPkg","proxyList","proxy","some","curr","item","match"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAGA;;;;AAEO,MAAMA,gBAAgB,GAAG,4BAAzB;;AACA,MAAMC,cAAc,GAAG,OAAvB;;AAEP,MAAMC,SAAS,GAAG;AAChBC,EAAAA,GAAG,EAAE,IADW;AAEhBC,EAAAA,SAAS,EAAE,IAFK;AAGhBC,EAAAA,SAAS,EAAE,IAHK;AAIhBC,EAAAA,KAAK,EAAE,IAJS;AAKhBC,EAAAA,IAAI,EAAE;AALU,CAAlB;;AAQO,SAASC,iBAAT,CACLC,OADK,EAELC,KAAU,GAAGR,SAFR,EAGY;AACjB,QAAMS,UAAU,GAAGC,gBAAEC,KAAF,CAAQJ,OAAR,CAAnB;;AACA,MAAIK,QAAQ,GAAGF,gBAAEC,KAAF,CAAQH,KAAR,CAAf;;AAEA,OAAK,MAAMK,MAAX,IAAqBJ,UAArB,EAAiC;AAC/B,QAAIK,MAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCR,UAArC,EAAiDI,MAAjD,CAAJ,EAA8D;AAC5D,UAAIH,gBAAEQ,KAAF,CAAQT,UAAU,CAACI,MAAD,CA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IAA1B,EAAwC3B,KAAxC,EAAyD;AAC9D,uBACE2B,IAAI,KAAK,KAAT,IACEA,IAAI,KAAK,OADX,IAEEA,IAAI,KAAK,WAFX,IAGEA,IAAI,KAAK,WAHX,IAIEA,IAAI,KAAK,MALb,EAME,mCAAmCA,IANrC;AAQA,uBAAO,CAACA,IAAI,CAACC,KAAL,CAAW,IAAX,CAAR,EAA0B,kCAAkCD,IAA5D;AACA,uBAAOzB,gBAAEQ,KAAF,CAAQV,KAAK,CAAC2B,IAAD,CAAb,CAAP,EAA6B,oCAAoCA,IAAjE;AACA3B,EAAAA,KAAK,CAAC2B,IAAD,CAAL,GAAc,IAAd;AAEA,SAAO3B,KAAP;AACD","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 (_.isNil(newUplinks[uplink].cache)) {\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"],"file":"uplinks.js"}
|
package/build/user.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.createRemoteUser = createRemoteUser;
|
|
7
6
|
exports.createAnonymousRemoteUser = createAnonymousRemoteUser;
|
|
7
|
+
exports.createRemoteUser = createRemoteUser;
|
|
8
8
|
exports.defaultNonLoggedUserRoles = exports.defaultLoggedUserRoles = void 0;
|
|
9
9
|
|
|
10
10
|
var _packageAccess = require("./package-access");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/config",
|
|
3
|
-
"version": "6.0.0-6-next.
|
|
3
|
+
"version": "6.0.0-6-next.12",
|
|
4
4
|
"description": "logger",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -26,17 +26,17 @@
|
|
|
26
26
|
"verdaccio"
|
|
27
27
|
],
|
|
28
28
|
"engines": {
|
|
29
|
-
"node": ">=
|
|
29
|
+
"node": ">=14",
|
|
30
30
|
"npm": ">=6"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@verdaccio/
|
|
34
|
-
"@verdaccio/utils": "6.0.0-6-next.
|
|
35
|
-
"debug": "4.3.
|
|
33
|
+
"@verdaccio/core": "6.0.0-6-next.4",
|
|
34
|
+
"@verdaccio/utils": "6.0.0-6-next.10",
|
|
35
|
+
"debug": "4.3.3",
|
|
36
36
|
"js-yaml": "3.14.1",
|
|
37
37
|
"lodash": "4.17.21",
|
|
38
38
|
"minimatch": "3.0.4",
|
|
39
|
-
"yup": "0.32.
|
|
39
|
+
"yup": "0.32.11"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/minimatch": "3.0.5",
|
package/src/config-path.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import buildDebug from 'debug';
|
|
1
2
|
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
3
|
import _ from 'lodash';
|
|
4
|
-
import
|
|
4
|
+
import path from 'path';
|
|
5
|
+
|
|
6
|
+
import { CHARACTER_ENCODING } from '@verdaccio/core';
|
|
5
7
|
|
|
6
|
-
import {
|
|
7
|
-
import { folderExists, fileExists } from './config-utils';
|
|
8
|
+
import { fileExists, folderExists } from './config-utils';
|
|
8
9
|
|
|
9
10
|
const CONFIG_FILE = 'config.yaml';
|
|
10
11
|
const XDG = 'xdg';
|
package/src/config.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
|
-
import _ from 'lodash';
|
|
3
2
|
import buildDebug from 'debug';
|
|
3
|
+
import _ from 'lodash';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { APP_ERROR } from '@verdaccio/commons-api';
|
|
5
|
+
import { APP_ERROR } from '@verdaccio/core';
|
|
7
6
|
import {
|
|
8
|
-
PackageList,
|
|
9
7
|
Config as AppConfig,
|
|
8
|
+
AuthConf,
|
|
10
9
|
ConfigRuntime,
|
|
11
|
-
Security,
|
|
12
10
|
PackageAccess,
|
|
11
|
+
PackageList,
|
|
12
|
+
Security,
|
|
13
13
|
ServerSettingsConf,
|
|
14
|
-
AuthConf,
|
|
15
14
|
} from '@verdaccio/types';
|
|
15
|
+
import { generateRandomHexString, getMatchedPackagesSpec, isObject } from '@verdaccio/utils';
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { getUserAgent } from './agent';
|
|
18
18
|
import { normalisePackageAccess } from './package-access';
|
|
19
|
-
import { sanityCheckUplinksProps, uplinkSanityCheck } from './uplinks';
|
|
20
19
|
import { defaultSecurity } from './security';
|
|
21
|
-
import { getUserAgent } from './agent';
|
|
22
20
|
import serverSettings from './serverSettings';
|
|
21
|
+
import { generateRandomSecretKey } from './token';
|
|
22
|
+
import { sanityCheckUplinksProps, uplinkSanityCheck } from './uplinks';
|
|
23
23
|
|
|
24
24
|
const strategicConfigProps = ['uplinks', 'packages'];
|
|
25
25
|
const allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];
|
package/src/package-access.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
2
|
import _ from 'lodash';
|
|
3
|
+
|
|
4
|
+
import { errorUtils } from '@verdaccio/core';
|
|
3
5
|
import { PackageAccess } from '@verdaccio/types';
|
|
4
|
-
|
|
6
|
+
|
|
5
7
|
export interface LegacyPackageList {
|
|
6
8
|
[key: string]: PackageAccess;
|
|
7
9
|
}
|
|
@@ -35,7 +37,7 @@ export function normalizeUserList(groupsList: any): any {
|
|
|
35
37
|
} else if (Array.isArray(groupsList)) {
|
|
36
38
|
result.push(groupsList);
|
|
37
39
|
} else {
|
|
38
|
-
throw
|
|
40
|
+
throw errorUtils.getInternalError(
|
|
39
41
|
'CONFIG: bad package acl (array or string expected): ' + JSON.stringify(groupsList)
|
|
40
42
|
);
|
|
41
43
|
}
|
package/src/parse.ts
CHANGED
package/src/uplinks.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
|
-
import { getMatchedPackagesSpec } from '@verdaccio/utils';
|
|
3
|
-
import { PackageList, UpLinksConfList } from '@verdaccio/types';
|
|
4
2
|
import _ from 'lodash';
|
|
5
3
|
|
|
4
|
+
import { PackageList, UpLinksConfList } from '@verdaccio/types';
|
|
5
|
+
import { getMatchedPackagesSpec } from '@verdaccio/utils';
|
|
6
|
+
|
|
6
7
|
export const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
|
7
8
|
export const DEFAULT_UPLINK = 'npmjs';
|
|
8
9
|
|
package/test/config.path.spec.ts
CHANGED
package/test/config.spec.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
1
|
import _ from 'lodash';
|
|
2
|
+
import path from 'path';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
Config,
|
|
6
6
|
DEFAULT_REGISTRY,
|
|
7
7
|
DEFAULT_UPLINK,
|
|
8
|
-
defaultSecurity,
|
|
9
|
-
parseConfigFile,
|
|
10
8
|
ROLES,
|
|
11
9
|
WEB_TITLE,
|
|
10
|
+
defaultSecurity,
|
|
11
|
+
parseConfigFile,
|
|
12
12
|
} from '../src';
|
|
13
13
|
import { parseConfigurationFile } from './utils';
|
|
14
14
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
|
|
3
|
-
import { normalisePackageAccess, PACKAGE_ACCESS } from '../src/package-access';
|
|
4
3
|
import { parseConfigFile } from '../src';
|
|
4
|
+
import { PACKAGE_ACCESS, normalisePackageAccess } from '../src/package-access';
|
|
5
5
|
import { parseConfigurationFile } from './utils';
|
|
6
6
|
|
|
7
7
|
describe('Package access utilities', () => {
|
package/test/token.spec.ts
CHANGED
package/test/uplinks.spec.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { hasProxyTo, sanityCheckUplinksProps, uplinkSanityCheck } from '../src/uplinks';
|
|
2
1
|
import { normalisePackageAccess, parseConfigFile } from '../src';
|
|
2
|
+
import { hasProxyTo, sanityCheckUplinksProps, uplinkSanityCheck } from '../src/uplinks';
|
|
3
3
|
import { parseConfigurationFile } from './utils';
|
|
4
4
|
|
|
5
5
|
describe('Uplinks Utilities', () => {
|
package/test/utils.spec.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { ROLES, createAnonymousRemoteUser, createRemoteUser } from '../src';
|
|
1
2
|
import { spliceURL } from '../src/string';
|
|
2
|
-
import { createAnonymousRemoteUser, createRemoteUser, ROLES } from '../src';
|
|
3
3
|
|
|
4
4
|
describe('spliceURL', () => {
|
|
5
5
|
test('should splice two strings and generate a url', () => {
|