@verdaccio/config 8.1.4 → 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 +22 -9
- package/build/index.js.map +0 -1
package/build/parse.js
CHANGED
|
@@ -1,109 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
-
const debug = (0, _debug.default)('verdaccio:config:parse');
|
|
19
|
-
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_config_utils = require("./config-utils.js");
|
|
3
|
+
const require_config_path = require("./config-path.js");
|
|
4
|
+
let debug = require("debug");
|
|
5
|
+
debug = require_runtime.__toESM(debug);
|
|
6
|
+
let lodash = require("lodash");
|
|
7
|
+
lodash = require_runtime.__toESM(lodash);
|
|
8
|
+
let _verdaccio_core = require("@verdaccio/core");
|
|
9
|
+
let node_fs = require("node:fs");
|
|
10
|
+
node_fs = require_runtime.__toESM(node_fs);
|
|
11
|
+
let node_path = require("node:path");
|
|
12
|
+
node_path = require_runtime.__toESM(node_path);
|
|
13
|
+
let js_yaml = require("js-yaml");
|
|
14
|
+
let node_module = require("node:module");
|
|
15
|
+
//#region src/parse.ts
|
|
16
|
+
var debug$1 = (0, debug.default)("verdaccio:config:parse");
|
|
20
17
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
* Parse a config file from yaml to JSON.
|
|
19
|
+
* @param configPath the absolute path of the configuration file
|
|
20
|
+
*/
|
|
24
21
|
function parseConfigFile(configPath) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
debug('config module not found %o error: %o', configPath, e.message);
|
|
51
|
-
throw Error(_core.APP_ERROR.CONFIG_NOT_VALID);
|
|
52
|
-
}
|
|
53
|
-
throw e;
|
|
54
|
-
}
|
|
22
|
+
debug$1("parse config file %s", configPath);
|
|
23
|
+
if (!require_config_utils.fileExists(configPath)) throw new Error(`config file does not exist or not reachable`);
|
|
24
|
+
debug$1("parsing config file: %o", configPath);
|
|
25
|
+
try {
|
|
26
|
+
if (/\.ya?ml$/i.test(configPath)) {
|
|
27
|
+
const content = node_fs.default.readFileSync(configPath, "utf8");
|
|
28
|
+
const yamlConfig = content.trim() === "" ? {} : (0, js_yaml.load)(content, { schema: js_yaml.YAML11_SCHEMA });
|
|
29
|
+
return Object.assign({}, yamlConfig, {
|
|
30
|
+
configPath,
|
|
31
|
+
config_path: configPath
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
_verdaccio_core.warningUtils.emit(_verdaccio_core.warningUtils.Codes.VERDEP004);
|
|
35
|
+
const jsonConfig = ({}.url ? (0, node_module.createRequire)({}.url) : (0, node_module.createRequire)(__filename))(configPath);
|
|
36
|
+
return Object.assign({}, jsonConfig, {
|
|
37
|
+
configPath,
|
|
38
|
+
config_path: configPath
|
|
39
|
+
});
|
|
40
|
+
} catch (e) {
|
|
41
|
+
if (e.code !== "MODULE_NOT_FOUND") {
|
|
42
|
+
debug$1("config module not found %o error: %o", configPath, e.message);
|
|
43
|
+
throw Error(_verdaccio_core.APP_ERROR.CONFIG_NOT_VALID);
|
|
44
|
+
}
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
55
47
|
}
|
|
56
48
|
function fromJStoYAML(config) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
} else {
|
|
61
|
-
throw new Error(`config is not a valid object`);
|
|
62
|
-
}
|
|
49
|
+
debug$1("convert config from JSON to YAML");
|
|
50
|
+
if (lodash.default.isObject(config)) return (0, js_yaml.dump)(config);
|
|
51
|
+
else throw new Error(`config is not a valid object`);
|
|
63
52
|
}
|
|
64
|
-
|
|
65
53
|
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
54
|
+
* Parses and returns a configuration object of type `ConfigYaml`.
|
|
55
|
+
*
|
|
56
|
+
* If a string or `undefined` is provided, it is interpreted as a path to a config file
|
|
57
|
+
* (or uses a default location). The config file is then loaded and parsed.
|
|
58
|
+
* If an object is provided, it is assumed to be a pre-parsed configuration.
|
|
59
|
+
* Backward compability: ensures the returned configuration object has a `self_path` property set,
|
|
60
|
+
* either to the config file path or to a property within the object.
|
|
61
|
+
*
|
|
62
|
+
* @param {string | ConfigYaml} [config] - Optional. A path to the configuration file (string),
|
|
63
|
+
* a pre-parsed config object, or `undefined`.
|
|
64
|
+
* @returns {ConfigYaml} The parsed configuration object with a guaranteed `self_path` property.
|
|
65
|
+
* @throws {Error} If the provided config is neither a string, undefined, nor an object.
|
|
66
|
+
*/
|
|
79
67
|
function getConfigParsed(config) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (!configurationParsed.self_path) {
|
|
99
|
-
debug('self_path not defined, using config path location');
|
|
100
|
-
|
|
101
|
-
// @ts-expect-error
|
|
102
|
-
configurationParsed.self_path = configurationParsed.configPath;
|
|
103
|
-
}
|
|
104
|
-
} else {
|
|
105
|
-
throw new Error(_core.API_ERROR.CONFIG_BAD_FORMAT);
|
|
106
|
-
}
|
|
107
|
-
return configurationParsed;
|
|
68
|
+
debug$1("getConfigParsed called with config: %o", typeof config);
|
|
69
|
+
let configurationParsed;
|
|
70
|
+
if (config === void 0 || typeof config === "string") {
|
|
71
|
+
debug$1("using default configuration");
|
|
72
|
+
const configPathLocation = require_config_path.findConfigFile(config);
|
|
73
|
+
configurationParsed = parseConfigFile(configPathLocation);
|
|
74
|
+
if (!configurationParsed.self_path) {
|
|
75
|
+
debug$1("self_path not defined, using config path location");
|
|
76
|
+
configurationParsed.self_path = node_path.default.resolve(configPathLocation);
|
|
77
|
+
}
|
|
78
|
+
} else if (typeof config === "object" && config !== null) {
|
|
79
|
+
configurationParsed = config;
|
|
80
|
+
if (!configurationParsed.self_path) {
|
|
81
|
+
debug$1("self_path not defined, using config path location");
|
|
82
|
+
configurationParsed.self_path = configurationParsed.configPath;
|
|
83
|
+
}
|
|
84
|
+
} else throw new Error(_verdaccio_core.API_ERROR.CONFIG_BAD_FORMAT);
|
|
85
|
+
return configurationParsed;
|
|
108
86
|
}
|
|
87
|
+
//#endregion
|
|
88
|
+
exports.fromJStoYAML = fromJStoYAML;
|
|
89
|
+
exports.getConfigParsed = getConfigParsed;
|
|
90
|
+
exports.parseConfigFile = parseConfigFile;
|
|
91
|
+
|
|
109
92
|
//# sourceMappingURL=parse.js.map
|
package/build/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","names":[
|
|
1
|
+
{"version":3,"file":"parse.js","names":[],"sources":["../src/parse.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { YAML11_SCHEMA, dump, load } from 'js-yaml';\nimport _ from 'lodash';\nimport fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport { API_ERROR, APP_ERROR, warningUtils } from '@verdaccio/core';\nimport type { 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 content = fs.readFileSync(configPath, 'utf8');\n // js-yaml v5 throws on empty input and defaults to the YAML 1.2 core\n // schema; keep the v4 behavior: an empty config parses as {} and the\n // YAML 1.1 schema preserves yes/no/on/off booleans and merge keys\n const yamlConfig =\n content.trim() === ''\n ? ({} as ConfigYaml)\n : (load(content, { schema: YAML11_SCHEMA }) as ConfigYaml);\n\n return Object.assign({}, yamlConfig, {\n configPath,\n // @deprecated use configPath instead\n config_path: configPath,\n });\n }\n\n warningUtils.emit(warningUtils.Codes.VERDEP004);\n // rolldown rewrites bare `require` to a throwing stub in the ESM output and\n // lowers `import.meta` to `{}` in the CJS output, so `import.meta.url` is\n // only truthy in the ESM build; module-scoped __filename covers the CJS\n // build (checking `typeof __filename`/`typeof require` instead is unsafe:\n // node -e and the REPL leak both as globals into ES modules)\n const requireFile = import.meta.url\n ? createRequire(import.meta.url)\n : createRequire(__filename);\n const jsonConfig = requireFile(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 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\n // @ts-expect-error\n if (!configurationParsed.self_path) {\n debug('self_path not defined, using config path location');\n\n // @ts-expect-error\n configurationParsed.self_path = path.resolve(configPathLocation);\n }\n } else if (typeof config === 'object' && config !== null) {\n configurationParsed = config;\n\n // @ts-expect-error\n if (!configurationParsed.self_path) {\n debug('self_path not defined, using config path location');\n\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,IAAM,WAAA,GAAA,MAAA,SAAmB,wBAAwB;;;;;AAMjD,SAAgB,gBAAgB,YAI9B;CACA,QAAM,wBAAwB,UAAU;CACxC,IAAI,CAAC,qBAAA,WAAW,UAAU,GACxB,MAAM,IAAI,MAAM,6CAA6C;CAE/D,QAAM,2BAA2B,UAAU;CAC3C,IAAI;EACF,IAAI,YAAY,KAAK,UAAU,GAAG;GAChC,MAAM,UAAU,QAAA,QAAG,aAAa,YAAY,MAAM;GAIlD,MAAM,aACJ,QAAQ,KAAK,MAAM,KACd,CAAC,KAAA,GAAA,QAAA,MACI,SAAS,EAAE,QAAQ,QAAA,cAAc,CAAC;GAE9C,OAAO,OAAO,OAAO,CAAC,GAAG,YAAY;IACnC;IAEA,aAAa;GACf,CAAC;EACH;EAEA,gBAAA,aAAa,KAAK,gBAAA,aAAa,MAAM,SAAS;EAS9C,MAAM,cAAA,CAAA,EAH0B,OAAA,GAAA,YAAA,eAAA,CAAA,EACF,GAAG,KAAA,GAAA,YAAA,eACf,UAAU,GACG,UAAU;EACzC,OAAO,OAAO,OAAO,CAAC,GAAG,YAAY;GACnC;GAEA,aAAa;EACf,CAAC;CACH,SAAS,GAAQ;EACf,IAAI,EAAE,SAAS,oBAAoB;GACjC,QAAM,wCAAwC,YAAY,EAAE,OAAO;GACnE,MAAM,MAAM,gBAAA,UAAU,gBAAgB;EACxC;EAEA,MAAM;CACR;AACF;AAEA,SAAgB,aAAa,QAA4C;CACvE,QAAM,kCAAkC;CACxC,IAAI,OAAA,QAAE,SAAS,MAAM,GACnB,QAAA,GAAA,QAAA,MAAY,MAAM;MAElB,MAAM,IAAI,MAAM,8BAA8B;AAElD;;;;;;;;;;;;;;;AAgBA,SAAgB,gBAAgB,QAA0C;CACxE,QAAM,0CAA0C,OAAO,MAAM;CAC7D,IAAI;CACJ,IAAI,WAAW,KAAA,KAAa,OAAO,WAAW,UAAU;EACtD,QAAM,6BAA6B;EACnC,MAAM,qBAAqB,oBAAA,eAAe,MAAM;EAChD,sBAAsB,gBAAgB,kBAAkB;EAGxD,IAAI,CAAC,oBAAoB,WAAW;GAClC,QAAM,mDAAmD;GAGzD,oBAAoB,YAAY,UAAA,QAAK,QAAQ,kBAAkB;EACjE;CACF,OAAO,IAAI,OAAO,WAAW,YAAY,WAAW,MAAM;EACxD,sBAAsB;EAGtB,IAAI,CAAC,oBAAoB,WAAW;GAClC,QAAM,mDAAmD;GAGzD,oBAAoB,YAAY,oBAAoB;EACtD;CACF,OACE,MAAM,IAAI,MAAM,gBAAA,UAAU,iBAAiB;CAE7C,OAAO;AACT"}
|
package/build/parse.mjs
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { fileExists } from "./config-utils.mjs";
|
|
2
|
+
import { findConfigFile } from "./config-path.mjs";
|
|
3
|
+
import buildDebug from "debug";
|
|
4
|
+
import _ from "lodash";
|
|
5
|
+
import { API_ERROR, APP_ERROR, warningUtils } from "@verdaccio/core";
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { YAML11_SCHEMA, dump, load } from "js-yaml";
|
|
9
|
+
import { createRequire } from "node:module";
|
|
10
|
+
//#region src/parse.ts
|
|
11
|
+
var debug = buildDebug("verdaccio:config:parse");
|
|
12
|
+
/**
|
|
13
|
+
* Parse a config file from yaml to JSON.
|
|
14
|
+
* @param configPath the absolute path of the configuration file
|
|
15
|
+
*/
|
|
16
|
+
function parseConfigFile(configPath) {
|
|
17
|
+
debug("parse config file %s", configPath);
|
|
18
|
+
if (!fileExists(configPath)) throw new Error(`config file does not exist or not reachable`);
|
|
19
|
+
debug("parsing config file: %o", configPath);
|
|
20
|
+
try {
|
|
21
|
+
if (/\.ya?ml$/i.test(configPath)) {
|
|
22
|
+
const content = fs.readFileSync(configPath, "utf8");
|
|
23
|
+
const yamlConfig = content.trim() === "" ? {} : load(content, { schema: YAML11_SCHEMA });
|
|
24
|
+
return Object.assign({}, yamlConfig, {
|
|
25
|
+
configPath,
|
|
26
|
+
config_path: configPath
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
warningUtils.emit(warningUtils.Codes.VERDEP004);
|
|
30
|
+
const jsonConfig = (import.meta.url ? createRequire(import.meta.url) : createRequire(__filename))(configPath);
|
|
31
|
+
return Object.assign({}, jsonConfig, {
|
|
32
|
+
configPath,
|
|
33
|
+
config_path: configPath
|
|
34
|
+
});
|
|
35
|
+
} catch (e) {
|
|
36
|
+
if (e.code !== "MODULE_NOT_FOUND") {
|
|
37
|
+
debug("config module not found %o error: %o", configPath, e.message);
|
|
38
|
+
throw Error(APP_ERROR.CONFIG_NOT_VALID);
|
|
39
|
+
}
|
|
40
|
+
throw e;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function fromJStoYAML(config) {
|
|
44
|
+
debug("convert config from JSON to YAML");
|
|
45
|
+
if (_.isObject(config)) return dump(config);
|
|
46
|
+
else throw new Error(`config is not a valid object`);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Parses and returns a configuration object of type `ConfigYaml`.
|
|
50
|
+
*
|
|
51
|
+
* If a string or `undefined` is provided, it is interpreted as a path to a config file
|
|
52
|
+
* (or uses a default location). The config file is then loaded and parsed.
|
|
53
|
+
* If an object is provided, it is assumed to be a pre-parsed configuration.
|
|
54
|
+
* Backward compability: ensures the returned configuration object has a `self_path` property set,
|
|
55
|
+
* either to the config file path or to a property within the object.
|
|
56
|
+
*
|
|
57
|
+
* @param {string | ConfigYaml} [config] - Optional. A path to the configuration file (string),
|
|
58
|
+
* a pre-parsed config object, or `undefined`.
|
|
59
|
+
* @returns {ConfigYaml} The parsed configuration object with a guaranteed `self_path` property.
|
|
60
|
+
* @throws {Error} If the provided config is neither a string, undefined, nor an object.
|
|
61
|
+
*/
|
|
62
|
+
function getConfigParsed(config) {
|
|
63
|
+
debug("getConfigParsed called with config: %o", typeof config);
|
|
64
|
+
let configurationParsed;
|
|
65
|
+
if (config === void 0 || typeof config === "string") {
|
|
66
|
+
debug("using default configuration");
|
|
67
|
+
const configPathLocation = findConfigFile(config);
|
|
68
|
+
configurationParsed = parseConfigFile(configPathLocation);
|
|
69
|
+
if (!configurationParsed.self_path) {
|
|
70
|
+
debug("self_path not defined, using config path location");
|
|
71
|
+
configurationParsed.self_path = path.resolve(configPathLocation);
|
|
72
|
+
}
|
|
73
|
+
} else if (typeof config === "object" && config !== null) {
|
|
74
|
+
configurationParsed = config;
|
|
75
|
+
if (!configurationParsed.self_path) {
|
|
76
|
+
debug("self_path not defined, using config path location");
|
|
77
|
+
configurationParsed.self_path = configurationParsed.configPath;
|
|
78
|
+
}
|
|
79
|
+
} else throw new Error(API_ERROR.CONFIG_BAD_FORMAT);
|
|
80
|
+
return configurationParsed;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { fromJStoYAML, getConfigParsed, parseConfigFile };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=parse.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.mjs","names":[],"sources":["../src/parse.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { YAML11_SCHEMA, dump, load } from 'js-yaml';\nimport _ from 'lodash';\nimport fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport { API_ERROR, APP_ERROR, warningUtils } from '@verdaccio/core';\nimport type { 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 content = fs.readFileSync(configPath, 'utf8');\n // js-yaml v5 throws on empty input and defaults to the YAML 1.2 core\n // schema; keep the v4 behavior: an empty config parses as {} and the\n // YAML 1.1 schema preserves yes/no/on/off booleans and merge keys\n const yamlConfig =\n content.trim() === ''\n ? ({} as ConfigYaml)\n : (load(content, { schema: YAML11_SCHEMA }) as ConfigYaml);\n\n return Object.assign({}, yamlConfig, {\n configPath,\n // @deprecated use configPath instead\n config_path: configPath,\n });\n }\n\n warningUtils.emit(warningUtils.Codes.VERDEP004);\n // rolldown rewrites bare `require` to a throwing stub in the ESM output and\n // lowers `import.meta` to `{}` in the CJS output, so `import.meta.url` is\n // only truthy in the ESM build; module-scoped __filename covers the CJS\n // build (checking `typeof __filename`/`typeof require` instead is unsafe:\n // node -e and the REPL leak both as globals into ES modules)\n const requireFile = import.meta.url\n ? createRequire(import.meta.url)\n : createRequire(__filename);\n const jsonConfig = requireFile(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 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\n // @ts-expect-error\n if (!configurationParsed.self_path) {\n debug('self_path not defined, using config path location');\n\n // @ts-expect-error\n configurationParsed.self_path = path.resolve(configPathLocation);\n }\n } else if (typeof config === 'object' && config !== null) {\n configurationParsed = config;\n\n // @ts-expect-error\n if (!configurationParsed.self_path) {\n debug('self_path not defined, using config path location');\n\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,IAAM,QAAQ,WAAW,wBAAwB;;;;;AAMjD,SAAgB,gBAAgB,YAI9B;CACA,MAAM,wBAAwB,UAAU;CACxC,IAAI,CAAC,WAAW,UAAU,GACxB,MAAM,IAAI,MAAM,6CAA6C;CAE/D,MAAM,2BAA2B,UAAU;CAC3C,IAAI;EACF,IAAI,YAAY,KAAK,UAAU,GAAG;GAChC,MAAM,UAAU,GAAG,aAAa,YAAY,MAAM;GAIlD,MAAM,aACJ,QAAQ,KAAK,MAAM,KACd,CAAC,IACD,KAAK,SAAS,EAAE,QAAQ,cAAc,CAAC;GAE9C,OAAO,OAAO,OAAO,CAAC,GAAG,YAAY;IACnC;IAEA,aAAa;GACf,CAAC;EACH;EAEA,aAAa,KAAK,aAAa,MAAM,SAAS;EAS9C,MAAM,cAHc,OAAO,KAAK,MAC5B,cAAc,OAAO,KAAK,GAAG,IAC7B,cAAc,UAAU,GACG,UAAU;EACzC,OAAO,OAAO,OAAO,CAAC,GAAG,YAAY;GACnC;GAEA,aAAa;EACf,CAAC;CACH,SAAS,GAAQ;EACf,IAAI,EAAE,SAAS,oBAAoB;GACjC,MAAM,wCAAwC,YAAY,EAAE,OAAO;GACnE,MAAM,MAAM,UAAU,gBAAgB;EACxC;EAEA,MAAM;CACR;AACF;AAEA,SAAgB,aAAa,QAA4C;CACvE,MAAM,kCAAkC;CACxC,IAAI,EAAE,SAAS,MAAM,GACnB,OAAO,KAAK,MAAM;MAElB,MAAM,IAAI,MAAM,8BAA8B;AAElD;;;;;;;;;;;;;;;AAgBA,SAAgB,gBAAgB,QAA0C;CACxE,MAAM,0CAA0C,OAAO,MAAM;CAC7D,IAAI;CACJ,IAAI,WAAW,KAAA,KAAa,OAAO,WAAW,UAAU;EACtD,MAAM,6BAA6B;EACnC,MAAM,qBAAqB,eAAe,MAAM;EAChD,sBAAsB,gBAAgB,kBAAkB;EAGxD,IAAI,CAAC,oBAAoB,WAAW;GAClC,MAAM,mDAAmD;GAGzD,oBAAoB,YAAY,KAAK,QAAQ,kBAAkB;EACjE;CACF,OAAO,IAAI,OAAO,WAAW,YAAY,WAAW,MAAM;EACxD,sBAAsB;EAGtB,IAAI,CAAC,oBAAoB,WAAW;GAClC,MAAM,mDAAmD;GAGzD,oBAAoB,YAAY,oBAAoB;EACtD;CACF,OACE,MAAM,IAAI,MAAM,UAAU,iBAAiB;CAE7C,OAAO;AACT"}
|
package/build/security.js
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
expiresIn: TIME_EXPIRATION_1H
|
|
13
|
-
},
|
|
14
|
-
verify: {}
|
|
15
|
-
};
|
|
16
|
-
const defaultApiTokenConf = {
|
|
17
|
-
legacy: true,
|
|
18
|
-
migrateToSecureLegacySignature: true
|
|
19
|
-
};
|
|
20
|
-
const defaultSecurity = exports.defaultSecurity = {
|
|
21
|
-
web: defaultWebTokenOptions,
|
|
22
|
-
api: defaultApiTokenConf
|
|
1
|
+
//#region src/security.ts
|
|
2
|
+
var TIME_EXPIRATION_1H = "1h";
|
|
3
|
+
var defaultSecurity = {
|
|
4
|
+
web: {
|
|
5
|
+
sign: { expiresIn: "1h" },
|
|
6
|
+
verify: {}
|
|
7
|
+
},
|
|
8
|
+
api: {
|
|
9
|
+
legacy: true,
|
|
10
|
+
migrateToSecureLegacySignature: true
|
|
11
|
+
}
|
|
23
12
|
};
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.TIME_EXPIRATION_1H = TIME_EXPIRATION_1H;
|
|
15
|
+
exports.defaultSecurity = defaultSecurity;
|
|
16
|
+
|
|
24
17
|
//# sourceMappingURL=security.js.map
|
package/build/security.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.js","names":[
|
|
1
|
+
{"version":3,"file":"security.js","names":[],"sources":["../src/security.ts"],"sourcesContent":["import type { APITokenOptions, JWTOptions, Security } from '@verdaccio/types';\n\n// TODO: get this from core package\nexport const TIME_EXPIRATION_1H = '1h';\n\nconst defaultWebTokenOptions: JWTOptions = {\n sign: {\n // The expiration token for the website is 7 days\n expiresIn: TIME_EXPIRATION_1H,\n },\n verify: {},\n};\n\nconst defaultApiTokenConf: APITokenOptions = {\n legacy: true,\n migrateToSecureLegacySignature: true,\n};\n\nexport const defaultSecurity: Security = {\n web: defaultWebTokenOptions,\n api: defaultApiTokenConf,\n};\n"],"mappings":";AAGA,IAAa,qBAAqB;AAelC,IAAa,kBAA4B;CACvC,KAAK;EAbL,MAAM,EAEJ,WAAA,KACF;EACA,QAAQ,CAAC;CASJ;CACL,KAAK;EANL,QAAQ;EACR,gCAAgC;CAK3B;AACP"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/security.ts
|
|
2
|
+
var TIME_EXPIRATION_1H = "1h";
|
|
3
|
+
var defaultSecurity = {
|
|
4
|
+
web: {
|
|
5
|
+
sign: { expiresIn: "1h" },
|
|
6
|
+
verify: {}
|
|
7
|
+
},
|
|
8
|
+
api: {
|
|
9
|
+
legacy: true,
|
|
10
|
+
migrateToSecureLegacySignature: true
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { TIME_EXPIRATION_1H, defaultSecurity };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=security.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.mjs","names":[],"sources":["../src/security.ts"],"sourcesContent":["import type { APITokenOptions, JWTOptions, Security } from '@verdaccio/types';\n\n// TODO: get this from core package\nexport const TIME_EXPIRATION_1H = '1h';\n\nconst defaultWebTokenOptions: JWTOptions = {\n sign: {\n // The expiration token for the website is 7 days\n expiresIn: TIME_EXPIRATION_1H,\n },\n verify: {},\n};\n\nconst defaultApiTokenConf: APITokenOptions = {\n legacy: true,\n migrateToSecureLegacySignature: true,\n};\n\nexport const defaultSecurity: Security = {\n web: defaultWebTokenOptions,\n api: defaultApiTokenConf,\n};\n"],"mappings":";AAGA,IAAa,qBAAqB;AAelC,IAAa,kBAA4B;CACvC,KAAK;EAbL,MAAM,EAEJ,WAAA,KACF;EACA,QAAQ,CAAC;CASJ;CACL,KAAK;EANL,QAAQ;EACR,gCAAgC;CAK3B;AACP"}
|
package/build/serverSettings.js
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// https://www.npmjs.com/package/express-rate-limit
|
|
9
|
-
// values are intended to be high, please customize based on own needs
|
|
10
|
-
rateLimit: {
|
|
11
|
-
windowMs: 1000,
|
|
12
|
-
max: 10000
|
|
13
|
-
},
|
|
14
|
-
// deprecated
|
|
15
|
-
keepAliveTimeout: 60
|
|
1
|
+
//#region src/serverSettings.ts
|
|
2
|
+
var serverSettings_default = {
|
|
3
|
+
rateLimit: {
|
|
4
|
+
windowMs: 1e3,
|
|
5
|
+
max: 1e4
|
|
6
|
+
},
|
|
7
|
+
keepAliveTimeout: 60
|
|
16
8
|
};
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.default = serverSettings_default;
|
|
11
|
+
|
|
17
12
|
//# sourceMappingURL=serverSettings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverSettings.js","names":[
|
|
1
|
+
{"version":3,"file":"serverSettings.js","names":[],"sources":["../src/serverSettings.ts"],"sourcesContent":["export default {\n // https://www.npmjs.com/package/express-rate-limit\n // values are intended to be high, please customize based on own needs\n rateLimit: {\n windowMs: 1000,\n max: 10000,\n },\n // deprecated\n keepAliveTimeout: 60,\n};\n"],"mappings":";AAAA,IAAA,yBAAe;CAGb,WAAW;EACT,UAAU;EACV,KAAK;CACP;CAEA,kBAAkB;AACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverSettings.mjs","names":[],"sources":["../src/serverSettings.ts"],"sourcesContent":["export default {\n // https://www.npmjs.com/package/express-rate-limit\n // values are intended to be high, please customize based on own needs\n rateLimit: {\n windowMs: 1000,\n max: 10000,\n },\n // deprecated\n keepAliveTimeout: 60,\n};\n"],"mappings":";AAAA,IAAA,yBAAe;CAGb,WAAW;EACT,UAAU;EACV,KAAK;CACP;CAEA,kBAAkB;AACpB"}
|
package/build/token.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.TOKEN_VALID_LENGTH = void 0;
|
|
7
|
-
exports.generateRandomSecretKey = generateRandomSecretKey;
|
|
8
|
-
var _nodeCrypto = require("node:crypto");
|
|
9
|
-
const TOKEN_VALID_LENGTH = exports.TOKEN_VALID_LENGTH = 32;
|
|
10
|
-
|
|
1
|
+
let node_crypto = require("node:crypto");
|
|
2
|
+
//#region src/token.ts
|
|
3
|
+
var TOKEN_VALID_LENGTH = 32;
|
|
11
4
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
* Secret key must have 32 characters.
|
|
6
|
+
*/
|
|
14
7
|
function generateRandomSecretKey() {
|
|
15
|
-
|
|
8
|
+
return (0, node_crypto.randomBytes)(32).toString("base64").substring(0, 32);
|
|
16
9
|
}
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.TOKEN_VALID_LENGTH = TOKEN_VALID_LENGTH;
|
|
12
|
+
exports.generateRandomSecretKey = generateRandomSecretKey;
|
|
13
|
+
|
|
17
14
|
//# 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":[],"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":";;AAEA,IAAa,qBAAqB;;;;AAKlC,SAAgB,0BAAkC;CAChD,QAAA,GAAA,YAAA,aAAA,EAAqC,EAAE,SAAS,QAAQ,EAAE,UAAU,GAAA,EAAqB;AAC3F"}
|
package/build/token.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
//#region src/token.ts
|
|
3
|
+
var TOKEN_VALID_LENGTH = 32;
|
|
4
|
+
/**
|
|
5
|
+
* Secret key must have 32 characters.
|
|
6
|
+
*/
|
|
7
|
+
function generateRandomSecretKey() {
|
|
8
|
+
return randomBytes(32).toString("base64").substring(0, 32);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { TOKEN_VALID_LENGTH, generateRandomSecretKey };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=token.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.mjs","names":[],"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":";;AAEA,IAAa,qBAAqB;;;;AAKlC,SAAgB,0BAAkC;CAChD,OAAO,YAAA,EAA8B,EAAE,SAAS,QAAQ,EAAE,UAAU,GAAA,EAAqB;AAC3F"}
|