@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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.__toESM = __toESM;
|
package/build/address.js
CHANGED
|
@@ -1,111 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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');
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
let debug = require("debug");
|
|
3
|
+
debug = require_runtime.__toESM(debug);
|
|
4
|
+
let _verdaccio_core = require("@verdaccio/core");
|
|
5
|
+
//#region src/address.ts
|
|
6
|
+
var debug$1 = (0, debug.default)("verdaccio:config:address");
|
|
12
7
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
8
|
+
* Parse an internet address
|
|
9
|
+
* Allow:
|
|
10
|
+
- https:localhost:1234 - protocol + host + port
|
|
11
|
+
- localhost:1234 - host + port
|
|
12
|
+
- 1234 - port
|
|
13
|
+
- http::1234 - protocol + port
|
|
14
|
+
- https://localhost:443/ - full url + https
|
|
15
|
+
- http://[::1]:443/ - ipv6
|
|
16
|
+
- unix:/tmp/http.sock - unix sockets
|
|
17
|
+
- https://unix:/tmp/http.sock - unix sockets (https)
|
|
18
|
+
* @param {*} urlAddress the internet address definition
|
|
19
|
+
* @return {Object|Null} literal object that represent the address parsed
|
|
20
|
+
*/
|
|
26
21
|
function parseAddress(urlAddress) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
};
|
|
22
|
+
const urlPattern = /^((https?):(\/\/)?)?((([^\/:]*)|\[([^\[\]]+)\]):)?(\d+)\/?$/.exec(urlAddress);
|
|
23
|
+
if (urlPattern) return {
|
|
24
|
+
proto: urlPattern[2] || _verdaccio_core.DEFAULT_PROTOCOL,
|
|
25
|
+
host: urlPattern[6] || urlPattern[7] || _verdaccio_core.DEFAULT_DOMAIN,
|
|
26
|
+
port: urlPattern[8] || _verdaccio_core.DEFAULT_PORT
|
|
27
|
+
};
|
|
28
|
+
const unixPattern = /^(?:(https?):\/\/)?unix:(\/.*)$/.exec(urlAddress);
|
|
29
|
+
if (!unixPattern) return null;
|
|
30
|
+
return {
|
|
31
|
+
host: unixPattern[2],
|
|
32
|
+
proto: unixPattern[1] || "unix",
|
|
33
|
+
path: unixPattern[2]
|
|
34
|
+
};
|
|
50
35
|
}
|
|
51
36
|
function addrToString(a) {
|
|
52
|
-
|
|
37
|
+
return a.proto === "unix" ? `unix:${a.host}` : `${a.proto}://${a.host}:${a.port}`;
|
|
53
38
|
}
|
|
54
|
-
|
|
55
39
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
40
|
+
* Retrieve all addresses defined in the config file.
|
|
41
|
+
* Verdaccio is able to listen multiple ports
|
|
42
|
+
* @param {String} argListen
|
|
43
|
+
* @param {String} configListen
|
|
44
|
+
* eg:
|
|
45
|
+
* listen:
|
|
46
|
+
- localhost:5555
|
|
47
|
+
- localhost:5557
|
|
48
|
+
@return {Array}
|
|
49
|
+
*/
|
|
66
50
|
function getListenAddress(listen, logger) {
|
|
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
|
-
if (listen.length > 1) {
|
|
101
|
-
logger.warn(`Multiple listen addresses are not supported, using the first valid one ${addrToString(firstValid)}`);
|
|
102
|
-
}
|
|
103
|
-
return firstValid;
|
|
104
|
-
}
|
|
105
|
-
const single = parseAddress(listen);
|
|
106
|
-
if (!single) {
|
|
107
|
-
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`);
|
|
108
|
-
}
|
|
109
|
-
return single;
|
|
51
|
+
debug$1("getListenAddress called with %o", listen);
|
|
52
|
+
if (!listen) {
|
|
53
|
+
debug$1("No listen address provided, using default");
|
|
54
|
+
return {
|
|
55
|
+
proto: _verdaccio_core.DEFAULT_PROTOCOL,
|
|
56
|
+
host: _verdaccio_core.DEFAULT_DOMAIN,
|
|
57
|
+
port: _verdaccio_core.DEFAULT_PORT
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (Array.isArray(listen)) {
|
|
61
|
+
const filteredListen = listen.filter((item) => typeof item === "string");
|
|
62
|
+
if (filteredListen.length === 0) throw new Error("Listen addresses array cannot be empty");
|
|
63
|
+
const invalid = [];
|
|
64
|
+
const valid = [];
|
|
65
|
+
for (const raw of filteredListen) {
|
|
66
|
+
const candidate = parseAddress(raw);
|
|
67
|
+
if (candidate) {
|
|
68
|
+
debug$1("valid listen address found: %o", candidate);
|
|
69
|
+
valid.push(candidate);
|
|
70
|
+
} else {
|
|
71
|
+
debug$1("invalid address found: %o", raw);
|
|
72
|
+
invalid.push(raw);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
invalid.forEach((bad) => logger.warn({ addr: bad }, "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"));
|
|
76
|
+
if (valid.length === 0) throw new Error("No valid listen addresses found in configuration array");
|
|
77
|
+
const firstValid = valid[0];
|
|
78
|
+
if (listen.length > 1) logger.warn(`Multiple listen addresses are not supported, using the first valid one ${addrToString(firstValid)}`);
|
|
79
|
+
return firstValid;
|
|
80
|
+
}
|
|
81
|
+
const single = parseAddress(listen);
|
|
82
|
+
if (!single) 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`);
|
|
83
|
+
return single;
|
|
110
84
|
}
|
|
85
|
+
//#endregion
|
|
86
|
+
exports.getListenAddress = getListenAddress;
|
|
87
|
+
exports.parseAddress = parseAddress;
|
|
88
|
+
|
|
111
89
|
//# sourceMappingURL=address.js.map
|
package/build/address.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.js","names":[
|
|
1
|
+
{"version":3,"file":"address.js","names":[],"sources":["../src/address.ts"],"sourcesContent":["import createDebug from 'debug';\n\nimport { DEFAULT_DOMAIN, DEFAULT_PORT, DEFAULT_PROTOCOL } from '@verdaccio/core';\nimport type { ListenAddress as ConfigListenAddress, 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(\n listen: ConfigListenAddress | string | undefined,\n logger: Logger\n): 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 const valid: ListenAddress[] = [];\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 valid.push(candidate);\n } else {\n debug('invalid address found: %o', raw);\n invalid.push(raw as string);\n }\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\n if (valid.length === 0) {\n throw new Error('No valid listen addresses found in configuration array');\n }\n\n const firstValid = valid[0];\n\n if (listen.length > 1) {\n logger.warn(\n `Multiple listen addresses are not supported, using the first valid one ${addrToString(\n firstValid\n )}`\n );\n }\n\n return firstValid;\n }\n\n const single = parseAddress(listen as string);\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":";;;;;AAKA,IAAM,WAAA,GAAA,MAAA,SAAoB,0BAA0B;;;;;;;;;;;;;;;AAuBpD,SAAgB,aAAa,YAA0C;CAKrE,MAAM,aAAa,8DAA8D,KAAK,UAAU;CAEhG,IAAI,YACF,OAAO;EACL,OAAO,WAAW,MAAM,gBAAA;EACxB,MAAM,WAAW,MAAM,WAAW,MAAM,gBAAA;EACxC,MAAM,WAAW,MAAM,gBAAA;CACzB;CAGF,MAAM,cAAc,kCAAkC,KAAK,UAAU;CACrE,IAAI,CAAC,aAGH,OAAO;CAGT,OAAO;EACL,MAAM,YAAY;EAClB,OAAO,YAAY,MAAM;EACzB,MAAM,YAAY;CACpB;AACF;AAEA,SAAS,aAAa,GAA0B;CAC9C,OAAO,EAAE,UAAU,SAAS,QAAQ,EAAE,SAAS,GAAG,EAAE,MAAM,KAAK,EAAE,KAAK,GAAG,EAAE;AAC7E;;;;;;;;;;;;AAaA,SAAgB,iBACd,QACA,QACe;CACf,QAAM,mCAAmC,MAAM;CAE/C,IAAI,CAAC,QAAQ;EACX,QAAM,2CAA2C;EACjD,OAAO;GAAE,OAAO,gBAAA;GAAkB,MAAM,gBAAA;GAAgB,MAAM,gBAAA;EAAa;CAC7E;CAEA,IAAI,MAAM,QAAQ,MAAM,GAAG;EACzB,MAAM,iBAAiB,OAAO,QAAQ,SAAS,OAAO,SAAS,QAAQ;EAEvE,IAAI,eAAe,WAAW,GAC5B,MAAM,IAAI,MAAM,wCAAwC;EAG1D,MAAM,UAAoB,CAAC;EAC3B,MAAM,QAAyB,CAAC;EAEhC,KAAK,MAAM,OAAO,gBAAgB;GAChC,MAAM,YAAY,aAAa,GAAa;GAC5C,IAAI,WAAW;IACb,QAAM,kCAAkC,SAAS;IACjD,MAAM,KAAK,SAAS;GACtB,OAAO;IACL,QAAM,6BAA6B,GAAG;IACtC,QAAQ,KAAK,GAAa;GAC5B;EACF;EAEA,QAAQ,SAAS,QACf,OAAO,KACL,EAAE,MAAM,IAAI,GACZ,mKAGF,CACF;EAEA,IAAI,MAAM,WAAW,GACnB,MAAM,IAAI,MAAM,wDAAwD;EAG1E,MAAM,aAAa,MAAM;EAEzB,IAAI,OAAO,SAAS,GAClB,OAAO,KACL,0EAA0E,aACxE,UACF,GACF;EAGF,OAAO;CACT;CAEA,MAAM,SAAS,aAAa,MAAgB;CAC5C,IAAI,CAAC,QACH,MAAM,IAAI,MACR,qBAAqB,OAAO,mIAG9B;CAEF,OAAO;AACT"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import buildDebug from "debug";
|
|
2
|
+
import { DEFAULT_DOMAIN, DEFAULT_PORT, DEFAULT_PROTOCOL } from "@verdaccio/core";
|
|
3
|
+
//#region src/address.ts
|
|
4
|
+
var debug = buildDebug("verdaccio:config:address");
|
|
5
|
+
/**
|
|
6
|
+
* Parse an internet address
|
|
7
|
+
* Allow:
|
|
8
|
+
- https:localhost:1234 - protocol + host + port
|
|
9
|
+
- localhost:1234 - host + port
|
|
10
|
+
- 1234 - port
|
|
11
|
+
- http::1234 - protocol + port
|
|
12
|
+
- https://localhost:443/ - full url + https
|
|
13
|
+
- http://[::1]:443/ - ipv6
|
|
14
|
+
- unix:/tmp/http.sock - unix sockets
|
|
15
|
+
- https://unix:/tmp/http.sock - unix sockets (https)
|
|
16
|
+
* @param {*} urlAddress the internet address definition
|
|
17
|
+
* @return {Object|Null} literal object that represent the address parsed
|
|
18
|
+
*/
|
|
19
|
+
function parseAddress(urlAddress) {
|
|
20
|
+
const urlPattern = /^((https?):(\/\/)?)?((([^\/:]*)|\[([^\[\]]+)\]):)?(\d+)\/?$/.exec(urlAddress);
|
|
21
|
+
if (urlPattern) return {
|
|
22
|
+
proto: urlPattern[2] || DEFAULT_PROTOCOL,
|
|
23
|
+
host: urlPattern[6] || urlPattern[7] || DEFAULT_DOMAIN,
|
|
24
|
+
port: urlPattern[8] || DEFAULT_PORT
|
|
25
|
+
};
|
|
26
|
+
const unixPattern = /^(?:(https?):\/\/)?unix:(\/.*)$/.exec(urlAddress);
|
|
27
|
+
if (!unixPattern) return null;
|
|
28
|
+
return {
|
|
29
|
+
host: unixPattern[2],
|
|
30
|
+
proto: unixPattern[1] || "unix",
|
|
31
|
+
path: unixPattern[2]
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function addrToString(a) {
|
|
35
|
+
return a.proto === "unix" ? `unix:${a.host}` : `${a.proto}://${a.host}:${a.port}`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Retrieve all addresses defined in the config file.
|
|
39
|
+
* Verdaccio is able to listen multiple ports
|
|
40
|
+
* @param {String} argListen
|
|
41
|
+
* @param {String} configListen
|
|
42
|
+
* eg:
|
|
43
|
+
* listen:
|
|
44
|
+
- localhost:5555
|
|
45
|
+
- localhost:5557
|
|
46
|
+
@return {Array}
|
|
47
|
+
*/
|
|
48
|
+
function getListenAddress(listen, logger) {
|
|
49
|
+
debug("getListenAddress called with %o", listen);
|
|
50
|
+
if (!listen) {
|
|
51
|
+
debug("No listen address provided, using default");
|
|
52
|
+
return {
|
|
53
|
+
proto: DEFAULT_PROTOCOL,
|
|
54
|
+
host: DEFAULT_DOMAIN,
|
|
55
|
+
port: DEFAULT_PORT
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (Array.isArray(listen)) {
|
|
59
|
+
const filteredListen = listen.filter((item) => typeof item === "string");
|
|
60
|
+
if (filteredListen.length === 0) throw new Error("Listen addresses array cannot be empty");
|
|
61
|
+
const invalid = [];
|
|
62
|
+
const valid = [];
|
|
63
|
+
for (const raw of filteredListen) {
|
|
64
|
+
const candidate = parseAddress(raw);
|
|
65
|
+
if (candidate) {
|
|
66
|
+
debug("valid listen address found: %o", candidate);
|
|
67
|
+
valid.push(candidate);
|
|
68
|
+
} else {
|
|
69
|
+
debug("invalid address found: %o", raw);
|
|
70
|
+
invalid.push(raw);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
invalid.forEach((bad) => logger.warn({ addr: bad }, "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"));
|
|
74
|
+
if (valid.length === 0) throw new Error("No valid listen addresses found in configuration array");
|
|
75
|
+
const firstValid = valid[0];
|
|
76
|
+
if (listen.length > 1) logger.warn(`Multiple listen addresses are not supported, using the first valid one ${addrToString(firstValid)}`);
|
|
77
|
+
return firstValid;
|
|
78
|
+
}
|
|
79
|
+
const single = parseAddress(listen);
|
|
80
|
+
if (!single) 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`);
|
|
81
|
+
return single;
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { getListenAddress, parseAddress };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=address.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.mjs","names":[],"sources":["../src/address.ts"],"sourcesContent":["import createDebug from 'debug';\n\nimport { DEFAULT_DOMAIN, DEFAULT_PORT, DEFAULT_PROTOCOL } from '@verdaccio/core';\nimport type { ListenAddress as ConfigListenAddress, 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(\n listen: ConfigListenAddress | string | undefined,\n logger: Logger\n): 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 const valid: ListenAddress[] = [];\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 valid.push(candidate);\n } else {\n debug('invalid address found: %o', raw);\n invalid.push(raw as string);\n }\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\n if (valid.length === 0) {\n throw new Error('No valid listen addresses found in configuration array');\n }\n\n const firstValid = valid[0];\n\n if (listen.length > 1) {\n logger.warn(\n `Multiple listen addresses are not supported, using the first valid one ${addrToString(\n firstValid\n )}`\n );\n }\n\n return firstValid;\n }\n\n const single = parseAddress(listen as string);\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":";;;AAKA,IAAM,QAAQ,WAAY,0BAA0B;;;;;;;;;;;;;;;AAuBpD,SAAgB,aAAa,YAA0C;CAKrE,MAAM,aAAa,8DAA8D,KAAK,UAAU;CAEhG,IAAI,YACF,OAAO;EACL,OAAO,WAAW,MAAM;EACxB,MAAM,WAAW,MAAM,WAAW,MAAM;EACxC,MAAM,WAAW,MAAM;CACzB;CAGF,MAAM,cAAc,kCAAkC,KAAK,UAAU;CACrE,IAAI,CAAC,aAGH,OAAO;CAGT,OAAO;EACL,MAAM,YAAY;EAClB,OAAO,YAAY,MAAM;EACzB,MAAM,YAAY;CACpB;AACF;AAEA,SAAS,aAAa,GAA0B;CAC9C,OAAO,EAAE,UAAU,SAAS,QAAQ,EAAE,SAAS,GAAG,EAAE,MAAM,KAAK,EAAE,KAAK,GAAG,EAAE;AAC7E;;;;;;;;;;;;AAaA,SAAgB,iBACd,QACA,QACe;CACf,MAAM,mCAAmC,MAAM;CAE/C,IAAI,CAAC,QAAQ;EACX,MAAM,2CAA2C;EACjD,OAAO;GAAE,OAAO;GAAkB,MAAM;GAAgB,MAAM;EAAa;CAC7E;CAEA,IAAI,MAAM,QAAQ,MAAM,GAAG;EACzB,MAAM,iBAAiB,OAAO,QAAQ,SAAS,OAAO,SAAS,QAAQ;EAEvE,IAAI,eAAe,WAAW,GAC5B,MAAM,IAAI,MAAM,wCAAwC;EAG1D,MAAM,UAAoB,CAAC;EAC3B,MAAM,QAAyB,CAAC;EAEhC,KAAK,MAAM,OAAO,gBAAgB;GAChC,MAAM,YAAY,aAAa,GAAa;GAC5C,IAAI,WAAW;IACb,MAAM,kCAAkC,SAAS;IACjD,MAAM,KAAK,SAAS;GACtB,OAAO;IACL,MAAM,6BAA6B,GAAG;IACtC,QAAQ,KAAK,GAAa;GAC5B;EACF;EAEA,QAAQ,SAAS,QACf,OAAO,KACL,EAAE,MAAM,IAAI,GACZ,mKAGF,CACF;EAEA,IAAI,MAAM,WAAW,GACnB,MAAM,IAAI,MAAM,wDAAwD;EAG1E,MAAM,aAAa,MAAM;EAEzB,IAAI,OAAO,SAAS,GAClB,OAAO,KACL,0EAA0E,aACxE,UACF,GACF;EAGF,OAAO;CACT;CAEA,MAAM,SAAS,aAAa,MAAgB;CAC5C,IAAI,CAAC,QACH,MAAM,IAAI,MACR,qBAAqB,OAAO,mIAG9B;CAEF,OAAO;AACT"}
|
package/build/agent.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.getUserAgent = getUserAgent;
|
|
7
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
let lodash = require("lodash");
|
|
3
|
+
lodash = require_runtime.__toESM(lodash);
|
|
4
|
+
//#region src/agent.ts
|
|
9
5
|
function getUserAgent(customUserAgent, version, name) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} else if (customUserAgent === false) {
|
|
15
|
-
return 'hidden';
|
|
16
|
-
}
|
|
17
|
-
return `${name}/${version}`;
|
|
6
|
+
if (customUserAgent === true) return `${name}/${version}`;
|
|
7
|
+
else if (lodash.default.isString(customUserAgent) && lodash.default.isEmpty(customUserAgent) === false) return customUserAgent;
|
|
8
|
+
else if (customUserAgent === false) return "hidden";
|
|
9
|
+
return `${name}/${version}`;
|
|
18
10
|
}
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.getUserAgent = getUserAgent;
|
|
13
|
+
|
|
19
14
|
//# sourceMappingURL=agent.js.map
|
package/build/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","names":[
|
|
1
|
+
{"version":3,"file":"agent.js","names":[],"sources":["../src/agent.ts"],"sourcesContent":["import _ from 'lodash';\n\nexport function getUserAgent(\n customUserAgent?: boolean | string,\n version?: string,\n name?: string\n): string {\n if (customUserAgent === true) {\n return `${name}/${version}`;\n } else if (_.isString(customUserAgent) && _.isEmpty(customUserAgent) === false) {\n return customUserAgent;\n } else if (customUserAgent === false) {\n return 'hidden';\n }\n\n return `${name}/${version}`;\n}\n"],"mappings":";;;;AAEA,SAAgB,aACd,iBACA,SACA,MACQ;CACR,IAAI,oBAAoB,MACtB,OAAO,GAAG,KAAK,GAAG;MACb,IAAI,OAAA,QAAE,SAAS,eAAe,KAAK,OAAA,QAAE,QAAQ,eAAe,MAAM,OACvE,OAAO;MACF,IAAI,oBAAoB,OAC7B,OAAO;CAGT,OAAO,GAAG,KAAK,GAAG;AACpB"}
|
package/build/agent.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
//#region src/agent.ts
|
|
3
|
+
function getUserAgent(customUserAgent, version, name) {
|
|
4
|
+
if (customUserAgent === true) return `${name}/${version}`;
|
|
5
|
+
else if (_.isString(customUserAgent) && _.isEmpty(customUserAgent) === false) return customUserAgent;
|
|
6
|
+
else if (customUserAgent === false) return "hidden";
|
|
7
|
+
return `${name}/${version}`;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { getUserAgent };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=agent.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.mjs","names":[],"sources":["../src/agent.ts"],"sourcesContent":["import _ from 'lodash';\n\nexport function getUserAgent(\n customUserAgent?: boolean | string,\n version?: string,\n name?: string\n): string {\n if (customUserAgent === true) {\n return `${name}/${version}`;\n } else if (_.isString(customUserAgent) && _.isEmpty(customUserAgent) === false) {\n return customUserAgent;\n } else if (customUserAgent === false) {\n return 'hidden';\n }\n\n return `${name}/${version}`;\n}\n"],"mappings":";;AAEA,SAAgB,aACd,iBACA,SACA,MACQ;CACR,IAAI,oBAAoB,MACtB,OAAO,GAAG,KAAK,GAAG;MACb,IAAI,EAAE,SAAS,eAAe,KAAK,EAAE,QAAQ,eAAe,MAAM,OACvE,OAAO;MACF,IAAI,oBAAoB,OAC7B,OAAO;CAGT,OAAO,GAAG,KAAK,GAAG;AACpB"}
|