@verdaccio/config 8.1.2 → 8.2.0
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/_virtual/_rolldown/runtime.js +23 -0
- package/build/address.js +80 -102
- package/build/address.js.map +1 -1
- package/build/address.mjs +86 -0
- package/build/address.mjs.map +1 -0
- package/build/agent.js +11 -16
- package/build/agent.js.map +1 -1
- package/build/agent.mjs +12 -0
- package/build/agent.mjs.map +1 -0
- package/build/builder.js +128 -131
- package/build/builder.js.map +1 -1
- package/build/builder.mjs +129 -0
- package/build/builder.mjs.map +1 -0
- package/build/conf/index.js +10 -11
- package/build/conf/index.js.map +1 -1
- package/build/conf/index.mjs +12 -0
- package/build/conf/index.mjs.map +1 -0
- package/build/config-path.js +154 -163
- package/build/config-path.js.map +1 -1
- package/build/config-path.mjs +171 -0
- package/build/config-path.mjs.map +1 -0
- package/build/config-utils.js +37 -41
- package/build/config-utils.js.map +1 -1
- package/build/config-utils.mjs +40 -0
- package/build/config-utils.mjs.map +1 -0
- package/build/config.js +154 -203
- package/build/config.js.map +1 -1
- package/build/config.mjs +153 -0
- package/build/config.mjs.map +1 -0
- package/build/index.js +52 -167
- package/build/index.mjs +14 -0
- package/build/package-access.js +52 -68
- package/build/package-access.js.map +1 -1
- package/build/package-access.mjs +52 -0
- package/build/package-access.mjs.map +1 -0
- package/build/parse.js +83 -100
- package/build/parse.js.map +1 -1
- package/build/parse.mjs +85 -0
- package/build/parse.mjs.map +1 -0
- package/build/security.js +15 -22
- package/build/security.js.map +1 -1
- package/build/security.mjs +16 -0
- package/build/security.mjs.map +1 -0
- package/build/serverSettings.js +10 -15
- package/build/serverSettings.js.map +1 -1
- package/build/serverSettings.mjs +12 -0
- package/build/serverSettings.mjs.map +1 -0
- package/build/token.js +10 -13
- package/build/token.js.map +1 -1
- package/build/token.mjs +13 -0
- package/build/token.mjs.map +1 -0
- package/build/uplinks.js +47 -55
- package/build/uplinks.js.map +1 -1
- package/build/uplinks.mjs +50 -0
- package/build/uplinks.mjs.map +1 -0
- package/build/user.js +42 -37
- package/build/user.js.map +1 -1
- package/build/user.mjs +48 -0
- package/build/user.mjs.map +1 -0
- package/package.json +43 -30
- package/build/index.js.map +0 -1
package/build/config-utils.js
CHANGED
|
@@ -1,48 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
-
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
const debug = (0, _debug.default)('verdaccio:config:config-utils');
|
|
12
|
-
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
let debug = require("debug");
|
|
3
|
+
debug = require_runtime.__toESM(debug);
|
|
4
|
+
let node_fs = require("node:fs");
|
|
5
|
+
node_fs = require_runtime.__toESM(node_fs);
|
|
6
|
+
//#region src/config-utils.ts
|
|
7
|
+
var debug$1 = (0, debug.default)("verdaccio:config:config-utils");
|
|
13
8
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
* Check whether the path already exist.
|
|
10
|
+
* @param {String} path
|
|
11
|
+
* @return {Boolean}
|
|
12
|
+
*/
|
|
18
13
|
function folderExists(path) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
14
|
+
try {
|
|
15
|
+
debug$1("check folder exist", path);
|
|
16
|
+
const isDirectory = node_fs.default.statSync(path).isDirectory();
|
|
17
|
+
debug$1("folder exist", isDirectory);
|
|
18
|
+
return isDirectory;
|
|
19
|
+
} catch {
|
|
20
|
+
debug$1("folder %s does not exist", path);
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
* Check whether the file already exist.
|
|
26
|
+
* @param {String} path
|
|
27
|
+
* @return {Boolean}
|
|
28
|
+
*/
|
|
36
29
|
function fileExists(path) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
30
|
+
try {
|
|
31
|
+
debug$1("check file exist", path);
|
|
32
|
+
const isFile = node_fs.default.statSync(path).isFile();
|
|
33
|
+
debug$1("file exist", isFile);
|
|
34
|
+
return isFile;
|
|
35
|
+
} catch {
|
|
36
|
+
debug$1("file %s does not exist", path);
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
47
39
|
}
|
|
40
|
+
//#endregion
|
|
41
|
+
exports.fileExists = fileExists;
|
|
42
|
+
exports.folderExists = folderExists;
|
|
43
|
+
|
|
48
44
|
//# sourceMappingURL=config-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-utils.js","names":[
|
|
1
|
+
{"version":3,"file":"config-utils.js","names":[],"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 {\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 {\n debug('file %s does not exist', path);\n return false;\n }\n}\n"],"mappings":";;;;;;AAGA,IAAM,WAAA,GAAA,MAAA,SAAmB,+BAA+B;;;;;;AAOxD,SAAgB,aAAa,MAAuB;CAClD,IAAI;EACF,QAAM,sBAAsB,IAAI;EAEhC,MAAM,cADO,QAAA,QAAG,SAAS,IACL,EAAK,YAAY;EACrC,QAAM,gBAAgB,WAAW;EACjC,OAAO;CACT,QAAQ;EACN,QAAM,4BAA4B,IAAI;EACtC,OAAO;CACT;AACF;;;;;;AAOA,SAAgB,WAAW,MAAuB;CAChD,IAAI;EACF,QAAM,oBAAoB,IAAI;EAE9B,MAAM,SADO,QAAA,QAAG,SAAS,IACV,EAAK,OAAO;EAC3B,QAAM,cAAc,MAAM;EAC1B,OAAO;CACT,QAAQ;EACN,QAAM,0BAA0B,IAAI;EACpC,OAAO;CACT;AACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import buildDebug from "debug";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
//#region src/config-utils.ts
|
|
4
|
+
var debug = buildDebug("verdaccio:config:config-utils");
|
|
5
|
+
/**
|
|
6
|
+
* Check whether the path already exist.
|
|
7
|
+
* @param {String} path
|
|
8
|
+
* @return {Boolean}
|
|
9
|
+
*/
|
|
10
|
+
function folderExists(path) {
|
|
11
|
+
try {
|
|
12
|
+
debug("check folder exist", path);
|
|
13
|
+
const isDirectory = fs.statSync(path).isDirectory();
|
|
14
|
+
debug("folder exist", isDirectory);
|
|
15
|
+
return isDirectory;
|
|
16
|
+
} catch {
|
|
17
|
+
debug("folder %s does not exist", path);
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check whether the file already exist.
|
|
23
|
+
* @param {String} path
|
|
24
|
+
* @return {Boolean}
|
|
25
|
+
*/
|
|
26
|
+
function fileExists(path) {
|
|
27
|
+
try {
|
|
28
|
+
debug("check file exist", path);
|
|
29
|
+
const isFile = fs.statSync(path).isFile();
|
|
30
|
+
debug("file exist", isFile);
|
|
31
|
+
return isFile;
|
|
32
|
+
} catch {
|
|
33
|
+
debug("file %s does not exist", path);
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { fileExists, folderExists };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=config-utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-utils.mjs","names":[],"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 {\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 {\n debug('file %s does not exist', path);\n return false;\n }\n}\n"],"mappings":";;;AAGA,IAAM,QAAQ,WAAW,+BAA+B;;;;;;AAOxD,SAAgB,aAAa,MAAuB;CAClD,IAAI;EACF,MAAM,sBAAsB,IAAI;EAEhC,MAAM,cADO,GAAG,SAAS,IACL,EAAK,YAAY;EACrC,MAAM,gBAAgB,WAAW;EACjC,OAAO;CACT,QAAQ;EACN,MAAM,4BAA4B,IAAI;EACtC,OAAO;CACT;AACF;;;;;;AAOA,SAAgB,WAAW,MAAuB;CAChD,IAAI;EACF,MAAM,oBAAoB,IAAI;EAE9B,MAAM,SADO,GAAG,SAAS,IACV,EAAK,OAAO;EAC3B,MAAM,cAAc,MAAM;EAC1B,OAAO;CACT,QAAQ;EACN,MAAM,0BAA0B,IAAI;EACpC,OAAO;CACT;AACF"}
|
package/build/config.js
CHANGED
|
@@ -1,209 +1,160 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
windowMs: 15 * 60 * 1000,
|
|
28
|
-
// 15 minutes
|
|
29
|
-
max: 1000
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_agent = require("./agent.js");
|
|
3
|
+
const require_package_access = require("./package-access.js");
|
|
4
|
+
const require_security = require("./security.js");
|
|
5
|
+
const require_serverSettings = require("./serverSettings.js");
|
|
6
|
+
const require_token = require("./token.js");
|
|
7
|
+
const require_uplinks = require("./uplinks.js");
|
|
8
|
+
let debug = require("debug");
|
|
9
|
+
debug = require_runtime.__toESM(debug);
|
|
10
|
+
let lodash = require("lodash");
|
|
11
|
+
lodash = require_runtime.__toESM(lodash);
|
|
12
|
+
let node_assert = require("node:assert");
|
|
13
|
+
node_assert = require_runtime.__toESM(node_assert);
|
|
14
|
+
let _verdaccio_core = require("@verdaccio/core");
|
|
15
|
+
//#region src/config.ts
|
|
16
|
+
var strategicConfigProps = ["uplinks", "packages"];
|
|
17
|
+
var allowedEnvConfig = [
|
|
18
|
+
"http_proxy",
|
|
19
|
+
"https_proxy",
|
|
20
|
+
"no_proxy"
|
|
21
|
+
];
|
|
22
|
+
var debug$1 = (0, debug.default)("verdaccio:config");
|
|
23
|
+
var WEB_TITLE = "Verdaccio";
|
|
24
|
+
var defaultUserRateLimiting = {
|
|
25
|
+
windowMs: 900 * 1e3,
|
|
26
|
+
max: 1e3
|
|
30
27
|
};
|
|
31
28
|
function isNodeVersionGreaterThan21() {
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
const [major, minor] = process.versions.node.split(".").map(Number);
|
|
30
|
+
return major > 21 || major === 21 && minor >= 0;
|
|
34
31
|
}
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
var TOKEN_VALID_LENGTH = 32;
|
|
37
33
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
debug('checking secret key init');
|
|
160
|
-
if (typeof secret === 'string' && _lodash.default.isEmpty(secret) === false) {
|
|
161
|
-
debug('checking secret key length %s', secret.length);
|
|
162
|
-
if (secret.length > TOKEN_VALID_LENGTH) {
|
|
163
|
-
if (isNodeVersionGreaterThan21()) {
|
|
164
|
-
debug('is node version greater than 21');
|
|
165
|
-
if (this.getMigrateToSecureLegacySignature() === true) {
|
|
166
|
-
this.secret = (0, _token.generateRandomSecretKey)();
|
|
167
|
-
debug('rewriting secret key with length %s', this.secret.length);
|
|
168
|
-
return this.secret;
|
|
169
|
-
}
|
|
170
|
-
// oops, user needs to generate a new secret key
|
|
171
|
-
debug('secret does not comply with the required length, current length %d, application will fail on startup', secret.length);
|
|
172
|
-
throw new Error(`Invalid storage secret key length, must be 32 characters long but is ${secret.length}.
|
|
173
|
-
The secret length in Node.js 22 or higher must be 32 characters long. Please consider generate a new one.
|
|
174
|
-
Learn more at https://verdaccio.org/docs/configuration/#.verdaccio-db`);
|
|
175
|
-
} else {
|
|
176
|
-
debug('is node version lower than 22');
|
|
177
|
-
if (this.getMigrateToSecureLegacySignature() === true) {
|
|
178
|
-
this.secret = (0, _token.generateRandomSecretKey)();
|
|
179
|
-
debug('rewriting secret key with length %s', this.secret.length);
|
|
180
|
-
return this.secret;
|
|
181
|
-
}
|
|
182
|
-
debug('triggering deprecation warning for secret key length %s', secret.length);
|
|
183
|
-
// still using Node.js versions previous to 22, but we need to emit a deprecation warning
|
|
184
|
-
// deprecation warning, secret key is too long and must be 32
|
|
185
|
-
// this will be removed in the next major release and will produce an error
|
|
186
|
-
_core.warningUtils.emit(_warningUtils.Codes.VERWAR007);
|
|
187
|
-
this.secret = secret;
|
|
188
|
-
return this.secret;
|
|
189
|
-
}
|
|
190
|
-
} else if (secret.length === TOKEN_VALID_LENGTH) {
|
|
191
|
-
debug('detected valid secret key length %s', secret.length);
|
|
192
|
-
this.secret = secret;
|
|
193
|
-
return this.secret;
|
|
194
|
-
}
|
|
195
|
-
debug('reusing previous key with length %s', secret.length);
|
|
196
|
-
this.secret = secret;
|
|
197
|
-
return this.secret;
|
|
198
|
-
} else {
|
|
199
|
-
// generate a new a secret key
|
|
200
|
-
// FUTURE: this might be an external secret key, perhaps within config file?
|
|
201
|
-
debug('generating a new secret key');
|
|
202
|
-
this.secret = (0, _token.generateRandomSecretKey)();
|
|
203
|
-
debug('generated a new secret key length %s', this.secret?.length);
|
|
204
|
-
return this.secret;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
34
|
+
* Coordinates the application configuration
|
|
35
|
+
*/
|
|
36
|
+
var Config = class {
|
|
37
|
+
user_agent;
|
|
38
|
+
uplinks;
|
|
39
|
+
packages;
|
|
40
|
+
users;
|
|
41
|
+
auth;
|
|
42
|
+
store;
|
|
43
|
+
server_id;
|
|
44
|
+
configPath;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated use configPath or config.getConfigPath();
|
|
47
|
+
*/
|
|
48
|
+
self_path;
|
|
49
|
+
storage;
|
|
50
|
+
plugins;
|
|
51
|
+
security;
|
|
52
|
+
server;
|
|
53
|
+
configOverrideOptions;
|
|
54
|
+
secret;
|
|
55
|
+
flags;
|
|
56
|
+
userRateLimit;
|
|
57
|
+
constructor(config, configOverrideOptions = { forceMigrateToSecureLegacySignature: true }) {
|
|
58
|
+
const self = this;
|
|
59
|
+
this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;
|
|
60
|
+
if (!config.configPath) {
|
|
61
|
+
config.configPath = config.config_path ?? config.self_path;
|
|
62
|
+
if (!config.configPath) throw new Error("configPath property is required");
|
|
63
|
+
}
|
|
64
|
+
this.configOverrideOptions = configOverrideOptions;
|
|
65
|
+
this.configPath = config.configPath;
|
|
66
|
+
this.self_path = this.configPath;
|
|
67
|
+
debug$1("config path: %s", this.configPath);
|
|
68
|
+
this.plugins = config.plugins;
|
|
69
|
+
this.security = lodash.default.merge(lodash.default.merge(require_security.defaultSecurity, { api: { migrateToSecureLegacySignature: this.configOverrideOptions.forceMigrateToSecureLegacySignature } }), config.security);
|
|
70
|
+
this.server = {
|
|
71
|
+
...require_serverSettings.default,
|
|
72
|
+
...config.server
|
|
73
|
+
};
|
|
74
|
+
this.flags = {
|
|
75
|
+
searchRemote: config.flags?.searchRemote ?? true,
|
|
76
|
+
changePassword: config.flags?.changePassword ?? false,
|
|
77
|
+
webLogin: config.flags?.webLogin ?? false,
|
|
78
|
+
createUser: config.flags?.createUser ?? false
|
|
79
|
+
};
|
|
80
|
+
this.user_agent = config.user_agent;
|
|
81
|
+
for (const configProp in config) if (self[configProp] == null) self[configProp] = config[configProp];
|
|
82
|
+
if (typeof this.user_agent === "undefined") {
|
|
83
|
+
debug$1("set default user agent");
|
|
84
|
+
this.user_agent = require_agent.getUserAgent(false);
|
|
85
|
+
}
|
|
86
|
+
this.userRateLimit = {
|
|
87
|
+
...defaultUserRateLimiting,
|
|
88
|
+
...config?.userRateLimit
|
|
89
|
+
};
|
|
90
|
+
(0, node_assert.default)(_verdaccio_core.validationUtils.isObject(config), _verdaccio_core.APP_ERROR.CONFIG_NOT_VALID);
|
|
91
|
+
strategicConfigProps.forEach(function(x) {
|
|
92
|
+
if (self[x] == null) self[x] = {};
|
|
93
|
+
(0, node_assert.default)(_verdaccio_core.validationUtils.isObject(self[x]), `CONFIG: bad "${x}" value (object expected)`);
|
|
94
|
+
});
|
|
95
|
+
this.uplinks = require_uplinks.sanityCheckUplinksProps(require_uplinks.uplinkSanityCheck(this.uplinks));
|
|
96
|
+
this.packages = require_package_access.normalisePackageAccess(self.packages);
|
|
97
|
+
allowedEnvConfig.forEach((envConf) => {
|
|
98
|
+
if (!(envConf in self)) self[envConf] = process.env[envConf] || process.env[envConf.toUpperCase()];
|
|
99
|
+
});
|
|
100
|
+
if (!this.server_id) this.server_id = _verdaccio_core.cryptoUtils.generateRandomHexString(6);
|
|
101
|
+
}
|
|
102
|
+
getMigrateToSecureLegacySignature() {
|
|
103
|
+
return this.security.api.migrateToSecureLegacySignature;
|
|
104
|
+
}
|
|
105
|
+
getConfigPath() {
|
|
106
|
+
return this.configPath;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Check for package spec
|
|
110
|
+
* @param pkgName - package name
|
|
111
|
+
* @returns package access
|
|
112
|
+
* @deprecated use core.authUtils instead
|
|
113
|
+
*/
|
|
114
|
+
getMatchedPackagesSpec(pkgName) {
|
|
115
|
+
return _verdaccio_core.authUtils.getMatchedPackagesSpec(pkgName, this.packages);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Verify if the secret complies with the required structure
|
|
119
|
+
* - If the secret is not provided, it will generate a new one
|
|
120
|
+
* - For any Node.js version the new secret will be 32 characters long (to allow compatibility with modern Node.js versions)
|
|
121
|
+
* - If the secret is provided:
|
|
122
|
+
* - If Node.js 22 or higher, the secret must be 32 characters long thus the application will fail on startup
|
|
123
|
+
* - If Node.js 21 or lower, the secret will be used as is but will display a deprecation warning
|
|
124
|
+
* - If the property `security.api.migrateToSecureLegacySignature` is provided and set to true, the secret will be
|
|
125
|
+
* generated with the new signature model
|
|
126
|
+
* @secret external secret key
|
|
127
|
+
*/
|
|
128
|
+
checkSecretKey(secret) {
|
|
129
|
+
debug$1("checking secret key init");
|
|
130
|
+
if (typeof secret === "string" && lodash.default.isEmpty(secret) === false) {
|
|
131
|
+
debug$1("checking secret key length %s", secret.length);
|
|
132
|
+
if (secret.length === TOKEN_VALID_LENGTH) {
|
|
133
|
+
debug$1("detected valid secret key length %s", secret.length);
|
|
134
|
+
this.secret = secret;
|
|
135
|
+
return this.secret;
|
|
136
|
+
}
|
|
137
|
+
if (this.getMigrateToSecureLegacySignature() === true) {
|
|
138
|
+
this.secret = require_token.generateRandomSecretKey();
|
|
139
|
+
debug$1("rewriting secret key with length %s", this.secret.length);
|
|
140
|
+
return this.secret;
|
|
141
|
+
}
|
|
142
|
+
debug$1("secret does not comply with the required length, current length %d", secret.length);
|
|
143
|
+
throw new Error(`Invalid storage secret key length, must be 32 characters long but is ${secret.length}.
|
|
144
|
+
The secret length in Node.js 22 or higher must be 32 characters long. Please consider generate a new one.
|
|
145
|
+
Learn more at https://verdaccio.org/docs/configuration/#.verdaccio-db`);
|
|
146
|
+
} else {
|
|
147
|
+
debug$1("generating a new secret key");
|
|
148
|
+
this.secret = require_token.generateRandomSecretKey();
|
|
149
|
+
debug$1("generated a new secret key length %s", this.secret?.length);
|
|
150
|
+
return this.secret;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
//#endregion
|
|
208
155
|
exports.Config = Config;
|
|
156
|
+
exports.WEB_TITLE = WEB_TITLE;
|
|
157
|
+
exports.defaultUserRateLimiting = defaultUserRateLimiting;
|
|
158
|
+
exports.isNodeVersionGreaterThan21 = isNodeVersionGreaterThan21;
|
|
159
|
+
|
|
209
160
|
//# sourceMappingURL=config.js.map
|
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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","createUser","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 type {\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 createUser: config.flags?.createUser ?? 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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[],"sources":["../src/config.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport assert from 'node:assert';\n\nimport { APP_ERROR, authUtils, cryptoUtils, validationUtils } from '@verdaccio/core';\nimport type {\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 createUser: config.flags?.createUser ?? 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 debug('detected valid secret key length %s', secret.length);\n this.secret = secret;\n return this.secret;\n }\n // Node.js 22+ removed the legacy AES APIs, so token signing only works\n // with a secret of exactly 32 characters: migrate legacy (64 characters)\n // or manually edited secrets, otherwise fail fast at startup instead of\n // failing later on the first signed token\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('secret does not comply with the required length, current length %d', secret.length);\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 // 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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