@verdaccio/config 8.0.0-next-8.18 → 8.0.0-next-8.20
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/build/address.d.ts +34 -0
- package/build/address.js +107 -0
- package/build/address.js.map +1 -0
- package/build/conf/default.yaml +10 -1
- package/build/conf/docker.yaml +10 -1
- package/build/conf/index.js +2 -2
- package/build/conf/index.js.map +1 -1
- package/build/config-path.js +18 -18
- package/build/config-path.js.map +1 -1
- package/build/config-utils.js +3 -3
- package/build/config-utils.js.map +1 -1
- package/build/config.js +3 -3
- package/build/config.js.map +1 -1
- package/build/index.d.ts +2 -1
- package/build/index.js +19 -0
- package/build/index.js.map +1 -1
- package/build/package-access.js +2 -2
- package/build/package-access.js.map +1 -1
- package/build/parse.d.ts +15 -0
- package/build/parse.js +50 -2
- package/build/parse.js.map +1 -1
- package/build/token.js +2 -2
- package/build/token.js.map +1 -1
- package/build/uplinks.js +6 -6
- package/build/uplinks.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Logger } from '@verdaccio/types';
|
|
2
|
+
export interface ListenAddress {
|
|
3
|
+
proto: string;
|
|
4
|
+
host?: string;
|
|
5
|
+
port?: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Parse an internet address
|
|
10
|
+
* Allow:
|
|
11
|
+
- https:localhost:1234 - protocol + host + port
|
|
12
|
+
- localhost:1234 - host + port
|
|
13
|
+
- 1234 - port
|
|
14
|
+
- http::1234 - protocol + port
|
|
15
|
+
- https://localhost:443/ - full url + https
|
|
16
|
+
- http://[::1]:443/ - ipv6
|
|
17
|
+
- unix:/tmp/http.sock - unix sockets
|
|
18
|
+
- https://unix:/tmp/http.sock - unix sockets (https)
|
|
19
|
+
* @param {*} urlAddress the internet address definition
|
|
20
|
+
* @return {Object|Null} literal object that represent the address parsed
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseAddress(urlAddress: string): ListenAddress | null;
|
|
23
|
+
/**
|
|
24
|
+
* Retrieve all addresses defined in the config file.
|
|
25
|
+
* Verdaccio is able to listen multiple ports
|
|
26
|
+
* @param {String} argListen
|
|
27
|
+
* @param {String} configListen
|
|
28
|
+
* eg:
|
|
29
|
+
* listen:
|
|
30
|
+
- localhost:5555
|
|
31
|
+
- localhost:5557
|
|
32
|
+
@return {Array}
|
|
33
|
+
*/
|
|
34
|
+
export declare function getListenAddress(listen: (string | void)[], logger: Logger): ListenAddress;
|
package/build/address.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getListenAddress = getListenAddress;
|
|
7
|
+
exports.parseAddress = parseAddress;
|
|
8
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
+
var _core = require("@verdaccio/core");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const debug = (0, _debug.default)('verdaccio:config:address');
|
|
12
|
+
/**
|
|
13
|
+
* Parse an internet address
|
|
14
|
+
* Allow:
|
|
15
|
+
- https:localhost:1234 - protocol + host + port
|
|
16
|
+
- localhost:1234 - host + port
|
|
17
|
+
- 1234 - port
|
|
18
|
+
- http::1234 - protocol + port
|
|
19
|
+
- https://localhost:443/ - full url + https
|
|
20
|
+
- http://[::1]:443/ - ipv6
|
|
21
|
+
- unix:/tmp/http.sock - unix sockets
|
|
22
|
+
- https://unix:/tmp/http.sock - unix sockets (https)
|
|
23
|
+
* @param {*} urlAddress the internet address definition
|
|
24
|
+
* @return {Object|Null} literal object that represent the address parsed
|
|
25
|
+
*/
|
|
26
|
+
function parseAddress(urlAddress) {
|
|
27
|
+
//
|
|
28
|
+
// TODO: refactor it to something more reasonable?
|
|
29
|
+
//
|
|
30
|
+
// protocol : // ( host )|( ipv6 ): port /
|
|
31
|
+
const urlPattern = /^((https?):(\/\/)?)?((([^\/:]*)|\[([^\[\]]+)\]):)?(\d+)\/?$/.exec(urlAddress);
|
|
32
|
+
if (urlPattern) {
|
|
33
|
+
return {
|
|
34
|
+
proto: urlPattern[2] || _core.DEFAULT_PROTOCOL,
|
|
35
|
+
host: urlPattern[6] || urlPattern[7] || _core.DEFAULT_DOMAIN,
|
|
36
|
+
port: urlPattern[8] || _core.DEFAULT_PORT
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const unixPattern = /^(?:(https?):\/\/)?unix:(\/.*)$/.exec(urlAddress);
|
|
40
|
+
if (!unixPattern) {
|
|
41
|
+
// if we cannot match the unix pattern, we return null
|
|
42
|
+
// this is to avoid returning a wrong object
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
host: unixPattern[2],
|
|
47
|
+
proto: unixPattern[1] || 'unix',
|
|
48
|
+
path: unixPattern[2]
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function addrToString(a) {
|
|
52
|
+
return a.proto === 'unix' ? `unix:${a.host}` : `${a.proto}://${a.host}:${a.port}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Retrieve all addresses defined in the config file.
|
|
57
|
+
* Verdaccio is able to listen multiple ports
|
|
58
|
+
* @param {String} argListen
|
|
59
|
+
* @param {String} configListen
|
|
60
|
+
* eg:
|
|
61
|
+
* listen:
|
|
62
|
+
- localhost:5555
|
|
63
|
+
- localhost:5557
|
|
64
|
+
@return {Array}
|
|
65
|
+
*/
|
|
66
|
+
function getListenAddress(listen, logger) {
|
|
67
|
+
debug('getListenAddress called with %o', listen);
|
|
68
|
+
if (!listen) {
|
|
69
|
+
debug('No listen address provided, using default');
|
|
70
|
+
return {
|
|
71
|
+
proto: _core.DEFAULT_PROTOCOL,
|
|
72
|
+
host: _core.DEFAULT_DOMAIN,
|
|
73
|
+
port: _core.DEFAULT_PORT
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (Array.isArray(listen)) {
|
|
77
|
+
const filteredListen = listen.filter(item => typeof item === 'string');
|
|
78
|
+
if (filteredListen.length === 0) {
|
|
79
|
+
throw new Error('Listen addresses array cannot be empty');
|
|
80
|
+
}
|
|
81
|
+
const invalid = [];
|
|
82
|
+
for (const raw of filteredListen) {
|
|
83
|
+
const candidate = parseAddress(raw);
|
|
84
|
+
if (candidate) {
|
|
85
|
+
debug('valid listen address found: %o', candidate);
|
|
86
|
+
invalid.forEach(bad => logger.warn({
|
|
87
|
+
addr: bad
|
|
88
|
+
}, 'invalid address - @{addr}, we expect a port (e.g. "4873"), ' + 'host:port (e.g. "localhost:4873"), full url ' + '(e.g. "http://localhost:4873/") or unix:/path/socket'));
|
|
89
|
+
if (listen.length > 1) {
|
|
90
|
+
logger.warn(`Multiple listen addresses are not supported, using the first valid one ${addrToString(candidate)}`);
|
|
91
|
+
}
|
|
92
|
+
return candidate;
|
|
93
|
+
}
|
|
94
|
+
invalid.push(raw);
|
|
95
|
+
}
|
|
96
|
+
invalid.forEach(bad => logger.warn({
|
|
97
|
+
addr: bad
|
|
98
|
+
}, 'invalid address - @{addr}, we expect a port (e.g. "4873"), ' + 'host:port (e.g. "localhost:4873"), full url ' + '(e.g. "http://localhost:4873/") or unix:/path/socket'));
|
|
99
|
+
throw new Error('No valid listen addresses found in configuration array');
|
|
100
|
+
}
|
|
101
|
+
const single = parseAddress(listen);
|
|
102
|
+
if (!single) {
|
|
103
|
+
throw new Error(`Invalid address - ${listen}, we expect a port (e.g. "4873"), ` + `host:port (e.g. "localhost:4873"), full url ` + `(e.g. "http://localhost:4873/") or unix:/path/socket`);
|
|
104
|
+
}
|
|
105
|
+
return single;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.js","names":["_debug","_interopRequireDefault","require","_core","e","__esModule","default","debug","createDebug","parseAddress","urlAddress","urlPattern","exec","proto","DEFAULT_PROTOCOL","host","DEFAULT_DOMAIN","port","DEFAULT_PORT","unixPattern","path","addrToString","a","getListenAddress","listen","logger","Array","isArray","filteredListen","filter","item","length","Error","invalid","raw","candidate","forEach","bad","warn","addr","push","single"],"sources":["../src/address.ts"],"sourcesContent":["import createDebug from 'debug';\n\nimport { DEFAULT_DOMAIN, DEFAULT_PORT, DEFAULT_PROTOCOL } from '@verdaccio/core';\nimport { Logger } from '@verdaccio/types';\n\nconst debug = createDebug('verdaccio:config:address');\n\nexport interface ListenAddress {\n proto: string;\n host?: string;\n port?: string;\n path?: string;\n}\n\n/**\n * Parse an internet address\n * Allow:\n - https:localhost:1234 - protocol + host + port\n - localhost:1234 - host + port\n - 1234 - port\n - http::1234 - protocol + port\n - https://localhost:443/ - full url + https\n - http://[::1]:443/ - ipv6\n - unix:/tmp/http.sock - unix sockets\n - https://unix:/tmp/http.sock - unix sockets (https)\n * @param {*} urlAddress the internet address definition\n * @return {Object|Null} literal object that represent the address parsed\n */\nexport function parseAddress(urlAddress: string): ListenAddress | null {\n //\n // TODO: refactor it to something more reasonable?\n //\n // protocol : // ( host )|( ipv6 ): port /\n const urlPattern = /^((https?):(\\/\\/)?)?((([^\\/:]*)|\\[([^\\[\\]]+)\\]):)?(\\d+)\\/?$/.exec(urlAddress);\n\n if (urlPattern) {\n return {\n proto: urlPattern[2] || DEFAULT_PROTOCOL,\n host: urlPattern[6] || urlPattern[7] || DEFAULT_DOMAIN,\n port: urlPattern[8] || DEFAULT_PORT,\n };\n }\n\n const unixPattern = /^(?:(https?):\\/\\/)?unix:(\\/.*)$/.exec(urlAddress);\n if (!unixPattern) {\n // if we cannot match the unix pattern, we return null\n // this is to avoid returning a wrong object\n return null;\n }\n\n return {\n host: unixPattern[2],\n proto: unixPattern[1] || 'unix',\n path: unixPattern[2],\n };\n}\n\nfunction addrToString(a: ListenAddress): string {\n return a.proto === 'unix' ? `unix:${a.host}` : `${a.proto}://${a.host}:${a.port}`;\n}\n\n/**\n * Retrieve all addresses defined in the config file.\n * Verdaccio is able to listen multiple ports\n * @param {String} argListen\n * @param {String} configListen\n * eg:\n * listen:\n - localhost:5555\n - localhost:5557\n @return {Array}\n */\nexport function getListenAddress(listen: (string | void)[], logger: Logger): ListenAddress {\n debug('getListenAddress called with %o', listen);\n\n if (!listen) {\n debug('No listen address provided, using default');\n return { proto: DEFAULT_PROTOCOL, host: DEFAULT_DOMAIN, port: DEFAULT_PORT };\n }\n\n if (Array.isArray(listen)) {\n const filteredListen = listen.filter((item) => typeof item === 'string');\n\n if (filteredListen.length === 0) {\n throw new Error('Listen addresses array cannot be empty');\n }\n\n const invalid: string[] = [];\n\n for (const raw of filteredListen) {\n const candidate = parseAddress(raw as string);\n if (candidate) {\n debug('valid listen address found: %o', candidate);\n\n invalid.forEach((bad) =>\n logger.warn(\n { addr: bad },\n 'invalid address - @{addr}, we expect a port (e.g. \"4873\"), ' +\n 'host:port (e.g. \"localhost:4873\"), full url ' +\n '(e.g. \"http://localhost:4873/\") or unix:/path/socket'\n )\n );\n\n if (listen.length > 1) {\n logger.warn(\n `Multiple listen addresses are not supported, using the first valid one ${addrToString(\n candidate\n )}`\n );\n }\n return candidate;\n }\n invalid.push(raw as string);\n }\n\n invalid.forEach((bad) =>\n logger.warn(\n { addr: bad },\n 'invalid address - @{addr}, we expect a port (e.g. \"4873\"), ' +\n 'host:port (e.g. \"localhost:4873\"), full url ' +\n '(e.g. \"http://localhost:4873/\") or unix:/path/socket'\n )\n );\n throw new Error('No valid listen addresses found in configuration array');\n }\n\n const single = parseAddress(listen);\n if (!single) {\n throw new Error(\n `Invalid address - ${listen}, we expect a port (e.g. \"4873\"), ` +\n `host:port (e.g. \"localhost:4873\"), full url ` +\n `(e.g. \"http://localhost:4873/\") or unix:/path/socket`\n );\n }\n return single;\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,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CAAC,wDAAwD,CAAC;EAC3E;EAEA,MAAMS,MAAM,GAAGhC,YAAY,CAACe,MAAM,CAAC;EACnC,IAAI,CAACiB,MAAM,EAAE;IACX,MAAM,IAAIT,KAAK,CACb,qBAAqBR,MAAM,oCAAoC,GAC7D,8CAA8C,GAC9C,sDACJ,CAAC;EACH;EACA,OAAOiB,MAAM;AACf","ignoreList":[]}
|
package/build/conf/default.yaml
CHANGED
|
@@ -210,7 +210,16 @@ middlewares:
|
|
|
210
210
|
|
|
211
211
|
# Log settings
|
|
212
212
|
# https://verdaccio.org/docs/logger
|
|
213
|
-
|
|
213
|
+
# Redaction: https://getpino.io/#/docs/redaction
|
|
214
|
+
# Synchronous logging: https://getpino.io/#/docs/asynchronous
|
|
215
|
+
log:
|
|
216
|
+
type: stdout
|
|
217
|
+
format: pretty
|
|
218
|
+
level: http
|
|
219
|
+
# redact:
|
|
220
|
+
# paths: ['req.header.authorization','req.header.cookie','req.remoteAddress','req.remotePort','ip','remoteIP','user','msg']
|
|
221
|
+
# censor: '<redacted>'
|
|
222
|
+
# sync: true
|
|
214
223
|
|
|
215
224
|
# Feature flags (experimental settings that can be changed or removed in the future)
|
|
216
225
|
# https://verdaccio.org/docs/configuration#experiments
|
package/build/conf/docker.yaml
CHANGED
|
@@ -210,7 +210,16 @@ middlewares:
|
|
|
210
210
|
|
|
211
211
|
# Log settings
|
|
212
212
|
# https://verdaccio.org/docs/logger
|
|
213
|
-
|
|
213
|
+
# Redaction: https://getpino.io/#/docs/redaction
|
|
214
|
+
# Synchronous logging: https://getpino.io/#/docs/asynchronous
|
|
215
|
+
log:
|
|
216
|
+
type: stdout
|
|
217
|
+
format: pretty
|
|
218
|
+
level: http
|
|
219
|
+
# redact:
|
|
220
|
+
# paths: ['req.header.authorization','req.header.cookie','req.remoteAddress','req.remotePort','ip','remoteIP','user','msg']
|
|
221
|
+
# censor: '<redacted>'
|
|
222
|
+
# sync: true
|
|
214
223
|
|
|
215
224
|
# Feature flags (experimental settings that can be changed or removed in the future)
|
|
216
225
|
# https://verdaccio.org/docs/configuration#experiments
|
package/build/conf/index.js
CHANGED
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getDefaultConfig = getDefaultConfig;
|
|
7
|
-
var
|
|
7
|
+
var _nodePath = require("node:path");
|
|
8
8
|
var _parse = require("../parse");
|
|
9
9
|
function getDefaultConfig(fileName = 'default.yaml') {
|
|
10
|
-
const file = (0,
|
|
10
|
+
const file = (0, _nodePath.join)(__dirname, `./${fileName}`);
|
|
11
11
|
return (0, _parse.parseConfigFile)(file);
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
package/build/conf/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["_nodePath","require","_parse","getDefaultConfig","fileName","file","join","__dirname","parseConfigFile"],"sources":["../../src/conf/index.ts"],"sourcesContent":["import { join } from 'node:path';\n\nimport { parseConfigFile } from '../parse';\n\nexport function getDefaultConfig(fileName: string = 'default.yaml') {\n const file = join(__dirname, `./${fileName}`);\n return parseConfigFile(file);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEO,SAASE,gBAAgBA,CAACC,QAAgB,GAAG,cAAc,EAAE;EAClE,MAAMC,IAAI,GAAG,IAAAC,cAAI,EAACC,SAAS,EAAE,KAAKH,QAAQ,EAAE,CAAC;EAC7C,OAAO,IAAAI,sBAAe,EAACH,IAAI,CAAC;AAC9B","ignoreList":[]}
|
package/build/config-path.js
CHANGED
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.findConfigFile = findConfigFile;
|
|
7
7
|
exports.readDefaultConfig = readDefaultConfig;
|
|
8
8
|
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
10
9
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
|
-
var
|
|
12
|
-
var
|
|
10
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
11
|
+
var _nodeOs = _interopRequireDefault(require("node:os"));
|
|
12
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
13
13
|
var _configUtils = require("./config-utils");
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
15
|
const CONFIG_FILE = 'config.yaml';
|
|
@@ -27,7 +27,7 @@ const debug = (0, _debug.default)('verdaccio:config:config-path');
|
|
|
27
27
|
function findConfigFile(configPath) {
|
|
28
28
|
debug('searching for config file %o', configPath);
|
|
29
29
|
if (typeof configPath !== 'undefined') {
|
|
30
|
-
const configLocation =
|
|
30
|
+
const configLocation = _nodePath.default.resolve(configPath);
|
|
31
31
|
debug('custom location %s', configLocation);
|
|
32
32
|
return configLocation;
|
|
33
33
|
}
|
|
@@ -52,25 +52,25 @@ function findConfigFile(configPath) {
|
|
|
52
52
|
function createConfigFile(configLocation) {
|
|
53
53
|
createConfigFolder(configLocation);
|
|
54
54
|
const defaultConfig = updateStorageLinks(configLocation, readDefaultConfig());
|
|
55
|
-
|
|
55
|
+
_nodeFs.default.writeFileSync(configLocation.path, defaultConfig);
|
|
56
56
|
return configLocation;
|
|
57
57
|
}
|
|
58
58
|
function readDefaultConfig() {
|
|
59
|
-
const pathDefaultConf =
|
|
59
|
+
const pathDefaultConf = _nodePath.default.resolve(__dirname, 'conf/default.yaml');
|
|
60
60
|
try {
|
|
61
61
|
debug('the path of default config used from %s', pathDefaultConf);
|
|
62
|
-
|
|
62
|
+
_nodeFs.default.accessSync(pathDefaultConf, _nodeFs.default.constants.R_OK);
|
|
63
63
|
debug('configuration file has enough permissions for reading');
|
|
64
64
|
} catch {
|
|
65
65
|
debug('configuration file does not have enough permissions for reading');
|
|
66
66
|
throw new TypeError('configuration file does not have enough permissions for reading');
|
|
67
67
|
}
|
|
68
|
-
return
|
|
68
|
+
return _nodeFs.default.readFileSync(pathDefaultConf, 'utf8');
|
|
69
69
|
}
|
|
70
70
|
function createConfigFolder(configLocation) {
|
|
71
|
-
const folder =
|
|
71
|
+
const folder = _nodePath.default.dirname(configLocation.path);
|
|
72
72
|
debug(`creating default config file folder at %o`, folder);
|
|
73
|
-
|
|
73
|
+
_nodeFs.default.mkdirSync(folder, {
|
|
74
74
|
recursive: true
|
|
75
75
|
});
|
|
76
76
|
debug(`folder %o created`, folder);
|
|
@@ -92,11 +92,11 @@ function updateStorageLinks(configLocation, defaultConfig) {
|
|
|
92
92
|
// $XDG_DATA_HOME defines the base directory relative to which user specific data
|
|
93
93
|
// files should be stored, If $XDG_DATA_HOME is either not set or empty, a default
|
|
94
94
|
// equal to $HOME/.local/share should be used.
|
|
95
|
-
let dataDir = process.env.XDG_DATA_HOME ||
|
|
95
|
+
let dataDir = process.env.XDG_DATA_HOME || _nodePath.default.join(process.env.HOME, '.local', 'share');
|
|
96
96
|
if ((0, _configUtils.folderExists)(dataDir)) {
|
|
97
97
|
debug(`previous storage located`);
|
|
98
98
|
debug(`update storage links to %s`, dataDir);
|
|
99
|
-
dataDir =
|
|
99
|
+
dataDir = _nodePath.default.resolve(_nodePath.default.join(dataDir, pkgJSON.name, 'storage'));
|
|
100
100
|
return defaultConfig.replace(/^storage: .\/storage$/m, `storage: ${dataDir}`);
|
|
101
101
|
}
|
|
102
102
|
debug(`could not find a previous storage location, skip override`);
|
|
@@ -133,12 +133,12 @@ function getConfigPaths() {
|
|
|
133
133
|
* @returns
|
|
134
134
|
*/
|
|
135
135
|
const getXDGDirectory = () => {
|
|
136
|
-
const xDGConfigPath = process.env.XDG_CONFIG_HOME || process.env.HOME &&
|
|
136
|
+
const xDGConfigPath = process.env.XDG_CONFIG_HOME || process.env.HOME && _nodePath.default.join(process.env.HOME, '.config');
|
|
137
137
|
debug('XDGConfig folder path %s', xDGConfigPath);
|
|
138
138
|
if (xDGConfigPath && (0, _configUtils.folderExists)(xDGConfigPath)) {
|
|
139
139
|
debug('XDGConfig folder path %s', xDGConfigPath);
|
|
140
140
|
return {
|
|
141
|
-
path:
|
|
141
|
+
path: _nodePath.default.join(xDGConfigPath, pkgJSON.name, CONFIG_FILE),
|
|
142
142
|
type: XDG
|
|
143
143
|
};
|
|
144
144
|
}
|
|
@@ -150,10 +150,10 @@ const getXDGDirectory = () => {
|
|
|
150
150
|
* @returns
|
|
151
151
|
*/
|
|
152
152
|
const getWindowsDirectory = () => {
|
|
153
|
-
if (
|
|
153
|
+
if (_nodeOs.default.platform() === 'win32' && process.env.APPDATA && (0, _configUtils.folderExists)(process.env.APPDATA)) {
|
|
154
154
|
debug('windows appdata folder path %s', process.env.APPDATA);
|
|
155
155
|
return {
|
|
156
|
-
path:
|
|
156
|
+
path: _nodePath.default.resolve(_nodePath.default.join(process.env.APPDATA, pkgJSON.name, CONFIG_FILE)),
|
|
157
157
|
type: 'win'
|
|
158
158
|
};
|
|
159
159
|
}
|
|
@@ -165,7 +165,7 @@ const getWindowsDirectory = () => {
|
|
|
165
165
|
* @returns
|
|
166
166
|
*/
|
|
167
167
|
const getRelativeDefaultDirectory = () => {
|
|
168
|
-
const relativePath =
|
|
168
|
+
const relativePath = _nodePath.default.resolve(_nodePath.default.join('.', pkgJSON.name, CONFIG_FILE));
|
|
169
169
|
debug('relative folder path %s', relativePath);
|
|
170
170
|
return {
|
|
171
171
|
path: relativePath,
|
|
@@ -178,7 +178,7 @@ const getRelativeDefaultDirectory = () => {
|
|
|
178
178
|
* @returns
|
|
179
179
|
*/
|
|
180
180
|
const getOldDirectory = () => {
|
|
181
|
-
const oldPath =
|
|
181
|
+
const oldPath = _nodePath.default.resolve(_nodePath.default.join('.', CONFIG_FILE));
|
|
182
182
|
debug('old folder path %s', oldPath);
|
|
183
183
|
return {
|
|
184
184
|
path: oldPath,
|
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,EAAEG,UAAU,CAAC;EACjD,IAAI,OAAOA,UAAU,KAAK,WAAW,EAAE;IACrC,MAAMC,cAAc,GAAGC,aAAI,CAACC,OAAO,CAACH,UAAU,CAAC;IAC/CH,KAAK,CAAC,oBAAoB,EAAEI,cAAc,CAAC;IAC3C,OAAOA,cAAc;EACvB;EAEA,MAAMG,WAA6B,GAAGC,cAAc,CAAC,CAAC;EACtDR,KAAK,CAAC,4BAA4B,EAAEO,WAAW,CAACE,MAAM,CAAC;EACvD,IAAIF,WAAW,CAACE,MAAM,KAAK,CAA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AACC,QAAQ,CAAC,CAAC,KAAK,OAAO,IAAInB,OAAO,CAACC,GAAG,CAACmB,OAAO,IAAI,IAAAf,yBAAY,EAACL,OAAO,CAACC,GAAG,CAACmB,OAAO,CAAC,EAAE;IACzFvD,KAAK,CAAC,gCAAgC,EAAEmC,OAAO,CAACC,GAAG,CAACmB,OAAO,CAAC;IAC5D,OAAO;MACLlD,IAAI,EAAEA,aAAI,CAACC,OAAO,CAACD,aAAI,CAACiC,IAAI,CAACH,OAAO,CAACC,GAAG,CAACmB,OAAO,EAAEzD,OAAO,CAACC,IAAI,EAAEH,WAAW,CAAC,CAAC;MAC7EqC,IAAI,EAAE;IACR,CAAC;EACH;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMY,2BAA2B,GAAGA,CAAA,KAAsB;EACxD,MAAMW,YAAY,GAAGnD,aAAI,CAACC,OAAO,CAACD,aAAI,CAACiC,IAAI,CAAC,GAAG,EAAExC,OAAO,CAACC,IAAI,EAAEH,WAAW,CAAC,CAAC;EAC5EI,KAAK,CAAC,yBAAyB,EAAEwD,YAAY,CAAC;EAC9C,OAAO;IACLnD,IAAI,EAAEmD,YAAY;IAClBvB,IAAI,EAAE;EACR,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMa,eAAe,GAAGA,CAAA,KAAsB;EAC5C,MAAMW,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","_lodash","_nodeFs","_nodeOs","_nodePath","_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 _ from 'lodash';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node: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,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,SAAA,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,iBAAI,CAACC,OAAO,CAACH,UAAU,CAAC;IAC/CH,KAAK,CAAC,oBAAoB,EAAEI,cAAc,CAAC;IAC3C,OAAOA,cAAc;EACvB;EAEA,MAAMG,WAA6B,GAAGC,cAAc,CAAC,CAAC;EACtDR,KAAK,CAAC,4BAA4B,EAAEO,WAAW,CAACE,MAAM,CAAC;EACvD,IAAIF,WAAW,CAACE,MAAM,KAAK,CAAC,EAAE;IAC5BT,KAAK,CAAC,yCAAyC,CAAC;IAChD;IACA,MAAM,IAAIU,KAAK,CAAC,yCAAyC,CAAC;EAC5D;;EAEA;EACA,MAAMC,WAAkC,GAAGC,eAAC,C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AAC,EAAE;IACzFvD,KAAK,CAAC,gCAAgC,EAAEmC,OAAO,CAACC,GAAG,CAACmB,OAAO,CAAC;IAC5D,OAAO;MACLlD,IAAI,EAAEA,iBAAI,CAACC,OAAO,CAACD,iBAAI,CAACiC,IAAI,CAACH,OAAO,CAACC,GAAG,CAACmB,OAAO,EAAEzD,OAAO,CAACC,IAAI,EAAEH,WAAW,CAAC,CAAC;MAC7EqC,IAAI,EAAE;IACR,CAAC;EACH;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMY,2BAA2B,GAAGA,CAAA,KAAsB;EACxD,MAAMW,YAAY,GAAGnD,iBAAI,CAACC,OAAO,CAACD,iBAAI,CAACiC,IAAI,CAAC,GAAG,EAAExC,OAAO,CAACC,IAAI,EAAEH,WAAW,CAAC,CAAC;EAC5EI,KAAK,CAAC,yBAAyB,EAAEwD,YAAY,CAAC;EAC9C,OAAO;IACLnD,IAAI,EAAEmD,YAAY;IAClBvB,IAAI,EAAE;EACR,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMa,eAAe,GAAGA,CAAA,KAAsB;EAC5C,MAAMW,OAAO,GAAGpD,iBAAI,CAACC,OAAO,CAACD,iBAAI,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":[]}
|
package/build/config-utils.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.fileExists = fileExists;
|
|
7
7
|
exports.folderExists = folderExists;
|
|
8
8
|
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
-
var
|
|
9
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
const debug = (0, _debug.default)('verdaccio:config:config-utils');
|
|
12
12
|
|
|
@@ -18,7 +18,7 @@ const debug = (0, _debug.default)('verdaccio:config:config-utils');
|
|
|
18
18
|
function folderExists(path) {
|
|
19
19
|
try {
|
|
20
20
|
debug('check folder exist', path);
|
|
21
|
-
const stat =
|
|
21
|
+
const stat = _nodeFs.default.statSync(path);
|
|
22
22
|
const isDirectory = stat.isDirectory();
|
|
23
23
|
debug('folder exist', isDirectory);
|
|
24
24
|
return isDirectory;
|
|
@@ -36,7 +36,7 @@ function folderExists(path) {
|
|
|
36
36
|
function fileExists(path) {
|
|
37
37
|
try {
|
|
38
38
|
debug('check file exist', path);
|
|
39
|
-
const stat =
|
|
39
|
+
const stat = _nodeFs.default.statSync(path);
|
|
40
40
|
const isFile = stat.isFile();
|
|
41
41
|
debug('file exist', isFile);
|
|
42
42
|
return isFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-utils.js","names":["_debug","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"file":"config-utils.js","names":["_debug","_interopRequireDefault","require","_nodeFs","e","__esModule","default","debug","buildDebug","folderExists","path","stat","fs","statSync","isDirectory","_","fileExists","isFile"],"sources":["../src/config-utils.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport fs from 'node:fs';\n\nconst debug = buildDebug('verdaccio:config:config-utils');\n\n/**\n * Check whether the path already exist.\n * @param {String} path\n * @return {Boolean}\n */\nexport function folderExists(path: string): boolean {\n try {\n debug('check folder exist', path);\n const stat = fs.statSync(path);\n const isDirectory = stat.isDirectory();\n debug('folder exist', isDirectory);\n return isDirectory;\n } catch (_: any) {\n debug('folder %s does not exist', path);\n return false;\n }\n}\n\n/**\n * Check whether the file already exist.\n * @param {String} path\n * @return {Boolean}\n */\nexport function fileExists(path: string): boolean {\n try {\n debug('check file exist', path);\n const stat = fs.statSync(path);\n const isFile = stat.isFile();\n debug('file exist', isFile);\n return isFile;\n } catch (_: any) {\n debug('file %s does not exist', path);\n return false;\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAyB,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEzB,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,+BAA+B,CAAC;;AAEzD;AACA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAACC,IAAY,EAAW;EAClD,IAAI;IACFH,KAAK,CAAC,oBAAoB,EAAEG,IAAI,CAAC;IACjC,MAAMC,IAAI,GAAGC,eAAE,CAACC,QAAQ,CAACH,IAAI,CAAC;IAC9B,MAAMI,WAAW,GAAGH,IAAI,CAACG,WAAW,CAAC,CAAC;IACtCP,KAAK,CAAC,cAAc,EAAEO,WAAW,CAAC;IAClC,OAAOA,WAAW;EACpB,CAAC,CAAC,OAAOC,CAAM,EAAE;IACfR,KAAK,CAAC,0BAA0B,EAAEG,IAAI,CAAC;IACvC,OAAO,KAAK;EACd;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASM,UAAUA,CAACN,IAAY,EAAW;EAChD,IAAI;IACFH,KAAK,CAAC,kBAAkB,EAAEG,IAAI,CAAC;IAC/B,MAAMC,IAAI,GAAGC,eAAE,CAACC,QAAQ,CAACH,IAAI,CAAC;IAC9B,MAAMO,MAAM,GAAGN,IAAI,CAACM,MAAM,CAAC,CAAC;IAC5BV,KAAK,CAAC,YAAY,EAAEU,MAAM,CAAC;IAC3B,OAAOA,MAAM;EACf,CAAC,CAAC,OAAOF,CAAM,EAAE;IACfR,KAAK,CAAC,wBAAwB,EAAEG,IAAI,CAAC;IACrC,OAAO,KAAK;EACd;AACF","ignoreList":[]}
|
package/build/config.js
CHANGED
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.defaultUserRateLimiting = exports.WEB_TITLE = exports.Config = void 0;
|
|
7
7
|
exports.isNodeVersionGreaterThan21 = isNodeVersionGreaterThan21;
|
|
8
|
-
var _assert = _interopRequireDefault(require("assert"));
|
|
9
8
|
var _debug = _interopRequireDefault(require("debug"));
|
|
10
9
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
|
+
var _nodeAssert = _interopRequireDefault(require("node:assert"));
|
|
11
11
|
var _core = require("@verdaccio/core");
|
|
12
12
|
var _warningUtils = require("@verdaccio/core/build/warning-utils");
|
|
13
13
|
var _agent = require("./agent");
|
|
@@ -100,14 +100,14 @@ class Config {
|
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
// some weird shell scripts are valid yaml files parsed as string
|
|
103
|
-
(0,
|
|
103
|
+
(0, _nodeAssert.default)(_core.validationUtils.isObject(config), _core.APP_ERROR.CONFIG_NOT_VALID);
|
|
104
104
|
|
|
105
105
|
// sanity check for strategic config properties
|
|
106
106
|
strategicConfigProps.forEach(function (x) {
|
|
107
107
|
if (self[x] == null) {
|
|
108
108
|
self[x] = {};
|
|
109
109
|
}
|
|
110
|
-
(0,
|
|
110
|
+
(0, _nodeAssert.default)(_core.validationUtils.isObject(self[x]), `CONFIG: bad "${x}" value (object expected)`);
|
|
111
111
|
});
|
|
112
112
|
this.uplinks = (0, _uplinks.sanityCheckUplinksProps)((0, _uplinks.uplinkSanityCheck)(this.uplinks));
|
|
113
113
|
this.packages = (0, _packageAccess.normalisePackageAccess)(self.packages);
|
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["_assert","_interopRequireDefault","require","_debug","_lodash","_core","_warningUtils","_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","server","defaultServerSettings","flags","searchRemote","changePassword","webLogin","user_agent","configProp","getUserAgent","userRateLimit","assert","validationUtils","isObject","APP_ERROR","CONFIG_NOT_VALID","forEach","x","uplinks","sanityCheckUplinksProps","uplinkSanityCheck","packages","normalisePackageAccess","envConf","toUpperCase","server_id","cryptoUtils","generateRandomHexString","getMigrateToSecureLegacySignature","getConfigPath","getMatchedPackagesSpec","pkgName","authUtils","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, authUtils, cryptoUtils, validationUtils, 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';\n\nimport { getUserAgent } from './agent';\nimport { normalisePackageAccess } from './package-access';\nimport { defaultSecurity } from './security';\nimport defaultServerSettings 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 store: any;\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 server: 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.server = { ...defaultServerSettings, ...config.server };\n this.flags = {\n searchRemote: config.flags?.searchRemote ?? true,\n changePassword: config.flags?.changePassword ?? false,\n webLogin: config.flags?.webLogin ?? 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(validationUtils.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(validationUtils.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 = cryptoUtils.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 * @param pkgName - package name\n * @returns package access\n * @deprecated use core.authUtils instead\n */\n public getMatchedPackagesSpec(pkgName: string): PackageAccess | void {\n // TODO: remove this method and replace by library utils\n return authUtils.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;AAaA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,eAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,MAA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ACM,MAAM,GAAG,IAAAG,8BAAuB,EAAC,CAAC;YACvCzE,KAAK,CAAC,qCAAqC,EAAE,IAAI,CAACsE,MAAM,CAACE,MAAM,CAAC;YAChE,OAAO,IAAI,CAACF,MAAM;UACpB;UACAtE,KAAK,CAAC,yDAAyD,EAAEsE,MAAM,CAACE,MAAM,CAAC;UAC/E;UACA;UACA;UACAE,kBAAY,CAACC,IAAI,CAACC,mBAAK,CAACC,SAAS,CAAC;UAClC,IAAI,CAACP,MAAM,GAAGA,MAAM;UACpB,OAAO,IAAI,CAACA,MAAM;QACpB;MACF,CAAC,MAAM,IAAIA,MAAM,CAACE,MAAM,KAAKxD,kBAAkB,EAAE;QAC/ChB,KAAK,CAAC,qCAAqC,EAAEsE,MAAM,CAACE,MAAM,CAAC;QAC3D,IAAI,CAACF,MAAM,GAAGA,MAAM;QACpB,OAAO,IAAI,CAACA,MAAM;MACpB;MACAtE,KAAK,CAAC,qCAAqC,EAAEsE,MAAM,CAACE,MAAM,CAAC;MAC3D,IAAI,CAACF,MAAM,GAAGA,MAAM;MACpB,OAAO,IAAI,CAACA,MAAM;IACpB,CAAC,MAAM;MACL;MACA;MACAtE,KAAK,CAAC,6BAA6B,CAAC;MACpC,IAAI,CAACsE,MAAM,GAAG,IAAAG,8BAAuB,EAAC,CAAC;MACvCzE,KAAK,CAAC,sCAAsC,EAAE,IAAI,CAACsE,MAAM,EAAEE,MAAM,CAAC;MAElE,OAAO,IAAI,CAACF,MAAM;IACpB;EACF;AACF;AAACnE,OAAA,CAAAc,MAAA,GAAAA,MAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"config.js","names":["_debug","_interopRequireDefault","require","_lodash","_nodeAssert","_core","_warningUtils","_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","server","defaultServerSettings","flags","searchRemote","changePassword","webLogin","user_agent","configProp","getUserAgent","userRateLimit","assert","validationUtils","isObject","APP_ERROR","CONFIG_NOT_VALID","forEach","x","uplinks","sanityCheckUplinksProps","uplinkSanityCheck","packages","normalisePackageAccess","envConf","toUpperCase","server_id","cryptoUtils","generateRandomHexString","getMigrateToSecureLegacySignature","getConfigPath","getMatchedPackagesSpec","pkgName","authUtils","checkSecretKey","secret","isEmpty","length","generateRandomSecretKey","warningUtils","emit","Codes","VERWAR007"],"sources":["../src/config.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport assert from 'node:assert';\n\nimport { APP_ERROR, authUtils, cryptoUtils, validationUtils, 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';\n\nimport { getUserAgent } from './agent';\nimport { normalisePackageAccess } from './package-access';\nimport { defaultSecurity } from './security';\nimport defaultServerSettings 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 store: any;\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 server: 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.server = { ...defaultServerSettings, ...config.server };\n this.flags = {\n searchRemote: config.flags?.searchRemote ?? true,\n changePassword: config.flags?.changePassword ?? false,\n webLogin: config.flags?.webLogin ?? 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(validationUtils.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(validationUtils.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 = cryptoUtils.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 * @param pkgName - package name\n * @returns package access\n * @deprecated use core.authUtils instead\n */\n public getMatchedPackagesSpec(pkgName: string): PackageAccess | void {\n // TODO: remove this method and replace by library utils\n return authUtils.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,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAaA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,eAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,MAAA,GA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,MAAM,GAAG,IAAAG,8BAAuB,EAAC,CAAC;YACvCzE,KAAK,CAAC,qCAAqC,EAAE,IAAI,CAACsE,MAAM,CAACE,MAAM,CAAC;YAChE,OAAO,IAAI,CAACF,MAAM;UACpB;UACAtE,KAAK,CAAC,yDAAyD,EAAEsE,MAAM,CAACE,MAAM,CAAC;UAC/E;UACA;UACA;UACAE,kBAAY,CAACC,IAAI,CAACC,mBAAK,CAACC,SAAS,CAAC;UAClC,IAAI,CAACP,MAAM,GAAGA,MAAM;UACpB,OAAO,IAAI,CAACA,MAAM;QACpB;MACF,CAAC,MAAM,IAAIA,MAAM,CAACE,MAAM,KAAKxD,kBAAkB,EAAE;QAC/ChB,KAAK,CAAC,qCAAqC,EAAEsE,MAAM,CAACE,MAAM,CAAC;QAC3D,IAAI,CAACF,MAAM,GAAGA,MAAM;QACpB,OAAO,IAAI,CAACA,MAAM;MACpB;MACAtE,KAAK,CAAC,qCAAqC,EAAEsE,MAAM,CAACE,MAAM,CAAC;MAC3D,IAAI,CAACF,MAAM,GAAGA,MAAM;MACpB,OAAO,IAAI,CAACA,MAAM;IACpB,CAAC,MAAM;MACL;MACA;MACAtE,KAAK,CAAC,6BAA6B,CAAC;MACpC,IAAI,CAACsE,MAAM,GAAG,IAAAG,8BAAuB,EAAC,CAAC;MACvCzE,KAAK,CAAC,sCAAsC,EAAE,IAAI,CAACsE,MAAM,EAAEE,MAAM,CAAC;MAElE,OAAO,IAAI,CAACF,MAAM;IACpB;EACF;AACF;AAACnE,OAAA,CAAAc,MAAA,GAAAA,MAAA","ignoreList":[]}
|
package/build/index.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ export * from './config-path';
|
|
|
3
3
|
export * from './token';
|
|
4
4
|
export * from './config-utils';
|
|
5
5
|
export * from './package-access';
|
|
6
|
-
export { fromJStoYAML, parseConfigFile } from './parse';
|
|
6
|
+
export { fromJStoYAML, parseConfigFile, getConfigParsed } from './parse';
|
|
7
7
|
export * from './uplinks';
|
|
8
8
|
export * from './security';
|
|
9
9
|
export * from './agent';
|
|
10
10
|
export * from './user';
|
|
11
11
|
export { default as ConfigBuilder } from './builder';
|
|
12
12
|
export { getDefaultConfig } from './conf';
|
|
13
|
+
export * from './address';
|
package/build/index.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
fromJStoYAML: true,
|
|
8
8
|
parseConfigFile: true,
|
|
9
|
+
getConfigParsed: true,
|
|
9
10
|
ConfigBuilder: true,
|
|
10
11
|
getDefaultConfig: true
|
|
11
12
|
};
|
|
@@ -21,6 +22,12 @@ Object.defineProperty(exports, "fromJStoYAML", {
|
|
|
21
22
|
return _parse.fromJStoYAML;
|
|
22
23
|
}
|
|
23
24
|
});
|
|
25
|
+
Object.defineProperty(exports, "getConfigParsed", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _parse.getConfigParsed;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
24
31
|
Object.defineProperty(exports, "getDefaultConfig", {
|
|
25
32
|
enumerable: true,
|
|
26
33
|
get: function () {
|
|
@@ -144,5 +151,17 @@ Object.keys(_user).forEach(function (key) {
|
|
|
144
151
|
});
|
|
145
152
|
var _builder = _interopRequireDefault(require("./builder"));
|
|
146
153
|
var _conf = require("./conf");
|
|
154
|
+
var _address = require("./address");
|
|
155
|
+
Object.keys(_address).forEach(function (key) {
|
|
156
|
+
if (key === "default" || key === "__esModule") return;
|
|
157
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
158
|
+
if (key in exports && exports[key] === _address[key]) return;
|
|
159
|
+
Object.defineProperty(exports, key, {
|
|
160
|
+
enumerable: true,
|
|
161
|
+
get: function () {
|
|
162
|
+
return _address[key];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
147
166
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
148
167
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_config","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_configPath","_token","_configUtils","_packageAccess","_parse","_uplinks","_security","_agent","_user","_builder","_interopRequireDefault","_conf","e","__esModule","default"],"sources":["../src/index.ts"],"sourcesContent":["export * from './config';\nexport * from './config-path';\nexport * from './token';\nexport * from './config-utils';\nexport * from './package-access';\nexport { fromJStoYAML, parseConfigFile } from './parse';\nexport * from './uplinks';\nexport * from './security';\nexport * from './agent';\nexport * from './user';\nexport { default as ConfigBuilder } from './builder';\nexport { getDefaultConfig } from './conf';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["_config","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_configPath","_token","_configUtils","_packageAccess","_parse","_uplinks","_security","_agent","_user","_builder","_interopRequireDefault","_conf","_address","e","__esModule","default"],"sources":["../src/index.ts"],"sourcesContent":["export * from './config';\nexport * from './config-path';\nexport * from './token';\nexport * from './config-utils';\nexport * from './package-access';\nexport { fromJStoYAML, parseConfigFile, getConfigParsed } from './parse';\nexport * from './uplinks';\nexport * from './security';\nexport * from './agent';\nexport * from './user';\nexport { default as ConfigBuilder } from './builder';\nexport { getDefaultConfig } from './conf';\nexport * from './address';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,OAAA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;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAS,KAAA,CAAAjB,GAAA;IAAA;EAAA;AAAA;AACA,IAAAkB,QAAA,GAAAC,sBAAA,CAAAvB,OAAA;AACA,IAAAwB,KAAA,GAAAxB,OAAA;AACA,IAAAyB,QAAA,GAAAzB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAuB,QAAA,EAAAtB,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAqB,QAAA,CAAArB,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAa,QAAA,CAAArB,GAAA;IAAA;EAAA;AAAA;AAA0B,SAAAmB,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
|
package/build/package-access.js
CHANGED
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.ROLES = exports.PACKAGE_ACCESS = void 0;
|
|
7
7
|
exports.normalisePackageAccess = normalisePackageAccess;
|
|
8
8
|
exports.normalizeUserList = normalizeUserList;
|
|
9
|
-
var _assert = _interopRequireDefault(require("assert"));
|
|
10
9
|
var _debug = _interopRequireDefault(require("debug"));
|
|
11
10
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
|
+
var _nodeAssert = _interopRequireDefault(require("node:assert"));
|
|
12
12
|
var _core = require("@verdaccio/core");
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
const debug = (0, _debug.default)('verdaccio:config:utils');
|
|
@@ -62,7 +62,7 @@ function normalisePackageAccess(packages) {
|
|
|
62
62
|
const packageAccess = packages[pkg];
|
|
63
63
|
debug('package access %s for %s ', packageAccess, pkg);
|
|
64
64
|
const isInvalid = _lodash.default.isObject(packageAccess) && _lodash.default.isArray(packageAccess) === false;
|
|
65
|
-
(0,
|
|
65
|
+
(0, _nodeAssert.default)(isInvalid, `CONFIG: bad "'${pkg}'" package description (object expected)`);
|
|
66
66
|
normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);
|
|
67
67
|
normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);
|
|
68
68
|
normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-access.js","names":["
|
|
1
|
+
{"version":3,"file":"package-access.js","names":["_debug","_interopRequireDefault","require","_lodash","_nodeAssert","_core","e","__esModule","default","debug","buildDebug","ROLES","exports","$ALL","ALL","$AUTH","$ANONYMOUS","DEPRECATED_ALL","DEPRECATED_AUTH","DEPRECATED_ANONYMOUS","PACKAGE_ACCESS","SCOPE","normalizeUserList","groupsList","result","_","isNil","isEmpty","isString","groupsArray","split","push","Array","isArray","errorUtils","getInternalError","JSON","stringify","flatten","normalisePackageAccess","packages","normalizedPkgs","access","publish","unpublish","proxy","pkg","Object","prototype","hasOwnProperty","call","packageAccess","isInvalid","isObject","assert","isUndefined"],"sources":["../src/package-access.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport assert from 'node:assert';\n\nimport { errorUtils } from '@verdaccio/core';\nimport { PackageAccess } from '@verdaccio/types';\n\nconst debug = buildDebug('verdaccio:config:utils');\n\nexport interface LegacyPackageList {\n [key: string]: PackageAccess;\n}\n\n// @deprecated use @verdaccio/core:authUtils\nexport const ROLES = {\n $ALL: '$all',\n ALL: 'all',\n $AUTH: '$authenticated',\n $ANONYMOUS: '$anonymous',\n DEPRECATED_ALL: '@all',\n DEPRECATED_AUTH: '@authenticated',\n DEPRECATED_ANONYMOUS: '@anonymous',\n};\n\n// @deprecated use @verdaccio/core:authUtils\nexport const PACKAGE_ACCESS = {\n SCOPE: '@*/*',\n ALL: '**',\n};\n\nexport function normalizeUserList(groupsList: any): any {\n const result: any[] = [];\n if (_.isNil(groupsList) || _.isEmpty(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 debug('package access %s for %s ', packageAccess, pkg);\n const isInvalid = _.isObject(packageAccess) && _.isArray(packageAccess) === false;\n assert(isInvalid, `CONFIG: bad \"'${pkg}'\" package description (object expected)`);\n\n normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);\n normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);\n normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);\n // if unpublish is not defined, we set to false to fallback in publish access\n normalizedPkgs[pkg].unpublish = _.isUndefined(packageAccess.unpublish)\n ? false\n : normalizeUserList(packageAccess.unpublish);\n }\n }\n\n return normalizedPkgs;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAH,sBAAA,CAAAC,OAAA;AAE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List":[]}
|
package/build/parse.d.ts
CHANGED
|
@@ -8,3 +8,18 @@ export declare function parseConfigFile(configPath: string): ConfigYaml & {
|
|
|
8
8
|
configPath: string;
|
|
9
9
|
};
|
|
10
10
|
export declare function fromJStoYAML(config: Partial<ConfigYaml>): string | null;
|
|
11
|
+
/**
|
|
12
|
+
* Parses and returns a configuration object of type `ConfigYaml`.
|
|
13
|
+
*
|
|
14
|
+
* If a string or `undefined` is provided, it is interpreted as a path to a config file
|
|
15
|
+
* (or uses a default location). The config file is then loaded and parsed.
|
|
16
|
+
* If an object is provided, it is assumed to be a pre-parsed configuration.
|
|
17
|
+
* Backward compability: ensures the returned configuration object has a `self_path` property set,
|
|
18
|
+
* either to the config file path or to a property within the object.
|
|
19
|
+
*
|
|
20
|
+
* @param {string | ConfigYaml} [config] - Optional. A path to the configuration file (string),
|
|
21
|
+
* a pre-parsed config object, or `undefined`.
|
|
22
|
+
* @returns {ConfigYaml} The parsed configuration object with a guaranteed `self_path` property.
|
|
23
|
+
* @throws {Error} If the provided config is neither a string, undefined, nor an object.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getConfigParsed(config?: string | ConfigYaml): ConfigYaml;
|
package/build/parse.js
CHANGED
|
@@ -4,12 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.fromJStoYAML = fromJStoYAML;
|
|
7
|
+
exports.getConfigParsed = getConfigParsed;
|
|
7
8
|
exports.parseConfigFile = parseConfigFile;
|
|
8
9
|
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
10
10
|
var _jsYaml = _interopRequireDefault(require("js-yaml"));
|
|
11
11
|
var _lodash = require("lodash");
|
|
12
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
13
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
12
14
|
var _core = require("@verdaccio/core");
|
|
15
|
+
var _configPath = require("./config-path");
|
|
13
16
|
var _configUtils = require("./config-utils");
|
|
14
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
18
|
const debug = (0, _debug.default)('verdaccio:config:parse');
|
|
@@ -26,7 +29,7 @@ function parseConfigFile(configPath) {
|
|
|
26
29
|
debug('parsing config file: %o', configPath);
|
|
27
30
|
try {
|
|
28
31
|
if (/\.ya?ml$/i.test(configPath)) {
|
|
29
|
-
const yamlConfig = _jsYaml.default.load(
|
|
32
|
+
const yamlConfig = _jsYaml.default.load(_nodeFs.default.readFileSync(configPath, 'utf8'), {
|
|
30
33
|
strict: false
|
|
31
34
|
});
|
|
32
35
|
return Object.assign({}, yamlConfig, {
|
|
@@ -57,4 +60,49 @@ function fromJStoYAML(config) {
|
|
|
57
60
|
throw new Error(`config is not a valid object`);
|
|
58
61
|
}
|
|
59
62
|
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Parses and returns a configuration object of type `ConfigYaml`.
|
|
66
|
+
*
|
|
67
|
+
* If a string or `undefined` is provided, it is interpreted as a path to a config file
|
|
68
|
+
* (or uses a default location). The config file is then loaded and parsed.
|
|
69
|
+
* If an object is provided, it is assumed to be a pre-parsed configuration.
|
|
70
|
+
* Backward compability: ensures the returned configuration object has a `self_path` property set,
|
|
71
|
+
* either to the config file path or to a property within the object.
|
|
72
|
+
*
|
|
73
|
+
* @param {string | ConfigYaml} [config] - Optional. A path to the configuration file (string),
|
|
74
|
+
* a pre-parsed config object, or `undefined`.
|
|
75
|
+
* @returns {ConfigYaml} The parsed configuration object with a guaranteed `self_path` property.
|
|
76
|
+
* @throws {Error} If the provided config is neither a string, undefined, nor an object.
|
|
77
|
+
*/
|
|
78
|
+
function getConfigParsed(config) {
|
|
79
|
+
debug('getConfigParsed called with config: %o', typeof config);
|
|
80
|
+
let configurationParsed;
|
|
81
|
+
if (config === undefined || typeof config === 'string') {
|
|
82
|
+
debug('using default configuration');
|
|
83
|
+
const configPathLocation = (0, _configPath.findConfigFile)(config);
|
|
84
|
+
configurationParsed = parseConfigFile(configPathLocation);
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
86
|
+
// @ts-expect-error
|
|
87
|
+
if (!configurationParsed.self_path) {
|
|
88
|
+
debug('self_path not defined, using config path location');
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
90
|
+
// @ts-expect-error
|
|
91
|
+
configurationParsed.self_path = _nodePath.default.resolve(configPathLocation);
|
|
92
|
+
}
|
|
93
|
+
} else if (typeof config === 'object' && config !== null) {
|
|
94
|
+
configurationParsed = config;
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
96
|
+
// @ts-expect-error
|
|
97
|
+
if (!configurationParsed.self_path) {
|
|
98
|
+
debug('self_path not defined, using config path location');
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
100
|
+
// @ts-expect-error
|
|
101
|
+
configurationParsed.self_path = configurationParsed.configPath;
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
throw new Error(_core.API_ERROR.CONFIG_BAD_FORMAT);
|
|
105
|
+
}
|
|
106
|
+
return configurationParsed;
|
|
107
|
+
}
|
|
60
108
|
//# sourceMappingURL=parse.js.map
|
package/build/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","names":["_debug","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"file":"parse.js","names":["_debug","_interopRequireDefault","require","_jsYaml","_lodash","_nodeFs","_nodePath","_core","_configPath","_configUtils","e","__esModule","default","debug","buildDebug","parseConfigFile","configPath","fileExists","Error","test","yamlConfig","YAML","load","fs","readFileSync","strict","Object","assign","config_path","jsonConfig","code","message","APP_ERROR","CONFIG_NOT_VALID","fromJStoYAML","config","isObject","dump","getConfigParsed","configurationParsed","undefined","configPathLocation","findConfigFile","self_path","path","resolve","API_ERROR","CONFIG_BAD_FORMAT"],"sources":["../src/parse.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport YAML from 'js-yaml';\nimport { isObject } from 'lodash';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { API_ERROR, APP_ERROR } from '@verdaccio/core';\nimport { ConfigYaml } from '@verdaccio/types';\n\nimport { findConfigFile } from './config-path';\nimport { fileExists } from './config-utils';\n\nconst debug = buildDebug('verdaccio:config:parse');\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): ConfigYaml & {\n // @deprecated use configPath instead\n config_path: string;\n configPath: string;\n} {\n debug('parse config file %s', configPath);\n if (!fileExists(configPath)) {\n throw new Error(`config file does not exist or not reachable`);\n }\n debug('parsing config file: %o', configPath);\n try {\n if (/\\.ya?ml$/i.test(configPath)) {\n const yamlConfig = YAML.load(fs.readFileSync(configPath, 'utf8'), {\n strict: false,\n }) as ConfigYaml;\n\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 debug('config module not found %o error: %o', configPath, e.message);\n throw Error(APP_ERROR.CONFIG_NOT_VALID);\n }\n\n throw e;\n }\n}\n\nexport function fromJStoYAML(config: Partial<ConfigYaml>): string | null {\n debug('convert config from JSON to YAML');\n if (isObject(config)) {\n return YAML.dump(config);\n } else {\n throw new Error(`config is not a valid object`);\n }\n}\n\n/**\n * Parses and returns a configuration object of type `ConfigYaml`.\n *\n * If a string or `undefined` is provided, it is interpreted as a path to a config file\n * (or uses a default location). The config file is then loaded and parsed.\n * If an object is provided, it is assumed to be a pre-parsed configuration.\n * Backward compability: ensures the returned configuration object has a `self_path` property set,\n * either to the config file path or to a property within the object.\n *\n * @param {string | ConfigYaml} [config] - Optional. A path to the configuration file (string),\n * a pre-parsed config object, or `undefined`.\n * @returns {ConfigYaml} The parsed configuration object with a guaranteed `self_path` property.\n * @throws {Error} If the provided config is neither a string, undefined, nor an object.\n */\nexport function getConfigParsed(config?: string | ConfigYaml): ConfigYaml {\n debug('getConfigParsed called with config: %o', typeof config);\n let configurationParsed: ConfigYaml;\n if (config === undefined || typeof config === 'string') {\n debug('using default configuration');\n const configPathLocation = findConfigFile(config);\n configurationParsed = parseConfigFile(configPathLocation);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n if (!configurationParsed.self_path) {\n debug('self_path not defined, using config path location');\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n configurationParsed.self_path = path.resolve(configPathLocation);\n }\n } else if (typeof config === 'object' && config !== null) {\n configurationParsed = config;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n if (!configurationParsed.self_path) {\n debug('self_path not defined, using config path location');\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n configurationParsed.self_path = configurationParsed.configPath;\n }\n } else {\n throw new Error(API_ERROR.CONFIG_BAD_FORMAT);\n }\n return configurationParsed;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,SAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEA,IAAAK,KAAA,GAAAL,OAAA;AAGA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAA4C,SAAAD,uBAAAS,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE5C,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,wBAAwB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ACL,MAAM,IAAIjB,KAAK,CAAC,8BAA8B,CAAC;EACjD;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASoB,eAAeA,CAACH,MAA4B,EAAc;EACxEtB,KAAK,CAAC,wCAAwC,EAAE,OAAOsB,MAAM,CAAC;EAC9D,IAAII,mBAA+B;EACnC,IAAIJ,MAAM,KAAKK,SAAS,IAAI,OAAOL,MAAM,KAAK,QAAQ,EAAE;IACtDtB,KAAK,CAAC,6BAA6B,CAAC;IACpC,MAAM4B,kBAAkB,GAAG,IAAAC,0BAAc,EAACP,MAAM,CAAC;IACjDI,mBAAmB,GAAGxB,eAAe,CAAC0B,kBAAkB,CAAC;IACzD;IACA;IACA,IAAI,CAACF,mBAAmB,CAACI,SAAS,EAAE;MAClC9B,KAAK,CAAC,mDAAmD,CAAC;MAC1D;MACA;MACA0B,mBAAmB,CAACI,SAAS,GAAGC,iBAAI,CAACC,OAAO,CAACJ,kBAAkB,CAAC;IAClE;EACF,CAAC,MAAM,IAAI,OAAON,MAAM,KAAK,QAAQ,IAAIA,MAAM,KAAK,IAAI,EAAE;IACxDI,mBAAmB,GAAGJ,MAAM;IAC5B;IACA;IACA,IAAI,CAACI,mBAAmB,CAACI,SAAS,EAAE;MAClC9B,KAAK,CAAC,mDAAmD,CAAC;MAC1D;MACA;MACA0B,mBAAmB,CAACI,SAAS,GAAGJ,mBAAmB,CAACvB,UAAU;IAChE;EACF,CAAC,MAAM;IACL,MAAM,IAAIE,KAAK,CAAC4B,eAAS,CAACC,iBAAiB,CAAC;EAC9C;EACA,OAAOR,mBAAmB;AAC5B","ignoreList":[]}
|
package/build/token.js
CHANGED
|
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.TOKEN_VALID_LENGTH = void 0;
|
|
7
7
|
exports.generateRandomSecretKey = generateRandomSecretKey;
|
|
8
|
-
var
|
|
8
|
+
var _nodeCrypto = require("node:crypto");
|
|
9
9
|
const TOKEN_VALID_LENGTH = exports.TOKEN_VALID_LENGTH = 32;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Secret key must have 32 characters.
|
|
13
13
|
*/
|
|
14
14
|
function generateRandomSecretKey() {
|
|
15
|
-
return (0,
|
|
15
|
+
return (0, _nodeCrypto.randomBytes)(TOKEN_VALID_LENGTH).toString('base64').substring(0, TOKEN_VALID_LENGTH);
|
|
16
16
|
}
|
|
17
17
|
//# sourceMappingURL=token.js.map
|
package/build/token.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","names":["
|
|
1
|
+
{"version":3,"file":"token.js","names":["_nodeCrypto","require","TOKEN_VALID_LENGTH","exports","generateRandomSecretKey","randomBytes","toString","substring"],"sources":["../src/token.ts"],"sourcesContent":["import { randomBytes } from 'node:crypto';\n\nexport const TOKEN_VALID_LENGTH = 32;\n\n/**\n * Secret key must have 32 characters.\n */\nexport function generateRandomSecretKey(): string {\n return randomBytes(TOKEN_VALID_LENGTH).toString('base64').substring(0, TOKEN_VALID_LENGTH);\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAEO,MAAMC,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,EAAE;;AAEpC;AACA;AACA;AACO,SAASE,uBAAuBA,CAAA,EAAW;EAChD,OAAO,IAAAC,uBAAW,EAACH,kBAAkB,CAAC,CAACI,QAAQ,CAAC,QAAQ,CAAC,CAACC,SAAS,CAAC,CAAC,EAAEL,kBAAkB,CAAC;AAC5F","ignoreList":[]}
|
package/build/uplinks.js
CHANGED
|
@@ -9,8 +9,8 @@ exports.hasProxyTo = hasProxyTo;
|
|
|
9
9
|
exports.sanityCheckNames = sanityCheckNames;
|
|
10
10
|
exports.sanityCheckUplinksProps = sanityCheckUplinksProps;
|
|
11
11
|
exports.uplinkSanityCheck = uplinkSanityCheck;
|
|
12
|
-
var _assert = _interopRequireDefault(require("assert"));
|
|
13
12
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
|
+
var _nodeAssert = _interopRequireDefault(require("node:assert"));
|
|
14
14
|
var _core = require("@verdaccio/core");
|
|
15
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
const DEFAULT_REGISTRY = exports.DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
|
@@ -39,8 +39,8 @@ function sanityCheckUplinksProps(configUpLinks) {
|
|
|
39
39
|
const uplinks = _lodash.default.clone(configUpLinks);
|
|
40
40
|
for (const uplink in uplinks) {
|
|
41
41
|
if (Object.prototype.hasOwnProperty.call(uplinks, uplink)) {
|
|
42
|
-
(0,
|
|
43
|
-
(0,
|
|
42
|
+
(0, _nodeAssert.default)(uplinks[uplink].url, 'CONFIG: no url for uplink: ' + uplink);
|
|
43
|
+
(0, _nodeAssert.default)(_lodash.default.isString(uplinks[uplink].url), 'CONFIG: wrong url format for uplink: ' + uplink);
|
|
44
44
|
uplinks[uplink].url = uplinks[uplink].url.replace(/\/$/, '');
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -58,9 +58,9 @@ function hasProxyTo(pkg, upLink, packages) {
|
|
|
58
58
|
return false;
|
|
59
59
|
}
|
|
60
60
|
function sanityCheckNames(item, users) {
|
|
61
|
-
(0,
|
|
62
|
-
(0,
|
|
63
|
-
(0,
|
|
61
|
+
(0, _nodeAssert.default)(item !== 'all' && item !== 'owner' && item !== 'anonymous' && item !== 'undefined' && item !== 'none', 'CONFIG: reserved uplink name: ' + item);
|
|
62
|
+
(0, _nodeAssert.default)(!item.match(/\s/), 'CONFIG: invalid uplink name: ' + item);
|
|
63
|
+
(0, _nodeAssert.default)(_lodash.default.isNil(users[item]), 'CONFIG: duplicate uplink name: ' + item);
|
|
64
64
|
users[item] = true;
|
|
65
65
|
return users;
|
|
66
66
|
}
|
package/build/uplinks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uplinks.js","names":["
|
|
1
|
+
{"version":3,"file":"uplinks.js","names":["_lodash","_interopRequireDefault","require","_nodeAssert","_core","e","__esModule","default","DEFAULT_REGISTRY","exports","DEFAULT_UPLINK","BLACKLIST","all","anonymous","undefined","owner","none","uplinkSanityCheck","uplinks","users","newUplinks","_","clone","newUsers","uplink","Object","prototype","hasOwnProperty","call","cache","sanityCheckNames","sanityCheckUplinksProps","configUpLinks","assert","url","isString","replace","getProxiesForPackage","pkg","packages","matchedPkg","authUtils","getMatchedPackagesSpec","proxy","hasProxyTo","upLink","proxyList","some","curr","item","match","isNil"],"sources":["../src/uplinks.ts"],"sourcesContent":["import _ from 'lodash';\nimport assert from 'node:assert';\n\nimport { authUtils } from '@verdaccio/core';\nimport { PackageList, UpLinksConfList } from '@verdaccio/types';\n\nexport const DEFAULT_REGISTRY = 'https://registry.npmjs.org';\nexport const DEFAULT_UPLINK = 'npmjs';\n\nconst BLACKLIST = {\n all: true,\n anonymous: true,\n undefined: true,\n owner: true,\n none: true,\n};\n\nexport function uplinkSanityCheck(\n uplinks: UpLinksConfList,\n users: any = BLACKLIST\n): UpLinksConfList {\n const newUplinks = _.clone(uplinks);\n let newUsers = _.clone(users);\n\n for (const uplink in newUplinks) {\n if (Object.prototype.hasOwnProperty.call(newUplinks, uplink)) {\n if (typeof newUplinks[uplink].cache === 'undefined') {\n newUplinks[uplink].cache = true;\n }\n newUsers = sanityCheckNames(uplink, newUsers);\n }\n }\n\n return newUplinks;\n}\n\nexport function sanityCheckUplinksProps(configUpLinks: UpLinksConfList): UpLinksConfList {\n const uplinks = _.clone(configUpLinks);\n\n for (const uplink in uplinks) {\n if (Object.prototype.hasOwnProperty.call(uplinks, uplink)) {\n assert(uplinks[uplink].url, 'CONFIG: no url for uplink: ' + uplink);\n assert(_.isString(uplinks[uplink].url), 'CONFIG: wrong url format for uplink: ' + uplink);\n uplinks[uplink].url = uplinks[uplink].url.replace(/\\/$/, '');\n }\n }\n\n return uplinks;\n}\n\nexport function getProxiesForPackage(pkg: string, packages: PackageList): string[] {\n const matchedPkg = authUtils.getMatchedPackagesSpec(pkg, packages);\n return matchedPkg?.proxy || [];\n}\n\nexport function hasProxyTo(pkg: string, upLink: string, packages: PackageList): boolean {\n const proxyList = getProxiesForPackage(pkg, packages);\n if (proxyList) {\n return proxyList.some((curr) => upLink === curr);\n }\n\n return false;\n}\n\nexport function sanityCheckNames(item: string, users: any): any {\n assert(\n item !== 'all' &&\n item !== 'owner' &&\n item !== 'anonymous' &&\n item !== 'undefined' &&\n item !== 'none',\n 'CONFIG: reserved uplink name: ' + item\n );\n assert(!item.match(/\\s/), 'CONFIG: invalid uplink name: ' + item);\n assert(_.isNil(users[item]), 'CONFIG: duplicate uplink name: ' + item);\n users[item] = true;\n\n return users;\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAA4C,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGrC,MAAMG,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,4BAA4B;AACrD,MAAME,cAAc,GAAAD,OAAA,CAAAC,cAAA,GAAG,OAAO;AAErC,MAAMC,SAAS,GAAG;EAChBC,GAAG,EAAE,IAAI;EACTC,SAAS,EAAE,IAAI;EACfC,SAAS,EAAE,IAAI;EACfC,KAAK,EAAE,IAAI;EACXC,IAAI,EAAE;AACR,CAAC;AAEM,SAASC,iBAAiBA,CAC/BC,OAAwB,EACxBC,KAAU,GAAGR,SAAS,EACL;EACjB,MAAMS,UAAU,GAAGC,eAAC,CAACC,KAAK,CAACJ,OAAO,CAAC;EACnC,IAAIK,QAAQ,GAAGF,eAAC,CAACC,KAAK,CAACH,KAAK,CAAC;EAE7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O,MAAc,EAAEN,QAAqB,EAAW;EACtF,MAAMO,SAAS,GAAGT,oBAAoB,CAACC,GAAG,EAAEC,QAAQ,CAAC;EACrD,IAAIO,SAAS,EAAE;IACb,OAAOA,SAAS,CAACC,IAAI,CAAEC,IAAI,IAAKH,MAAM,KAAKG,IAAI,CAAC;EAClD;EAEA,OAAO,KAAK;AACd;AAEO,SAASlB,gBAAgBA,CAACmB,IAAY,EAAE9B,KAAU,EAAO;EAC9D,IAAAc,mBAAM,EACJgB,IAAI,KAAK,KAAK,IACZA,IAAI,KAAK,OAAO,IAChBA,IAAI,KAAK,WAAW,IACpBA,IAAI,KAAK,WAAW,IACpBA,IAAI,KAAK,MAAM,EACjB,gCAAgC,GAAGA,IACrC,CAAC;EACD,IAAAhB,mBAAM,EAAC,CAACgB,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE,+BAA+B,GAAGD,IAAI,CAAC;EACjE,IAAAhB,mBAAM,EAACZ,eAAC,CAAC8B,KAAK,CAAChC,KAAK,CAAC8B,IAAI,CAAC,CAAC,EAAE,iCAAiC,GAAGA,IAAI,CAAC;EACtE9B,KAAK,CAAC8B,IAAI,CAAC,GAAG,IAAI;EAElB,OAAO9B,KAAK;AACd","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.20",
|
|
4
4
|
"description": "Verdaccio Configuration",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"node": ">=18"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@verdaccio/core": "8.0.0-next-8.
|
|
36
|
+
"@verdaccio/core": "8.0.0-next-8.20",
|
|
37
37
|
"debug": "4.4.1",
|
|
38
38
|
"js-yaml": "4.1.0",
|
|
39
39
|
"lodash": "4.17.21",
|