@verdaccio/config 9.0.0-next-9.3 → 9.0.0-next-9.4
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/_virtual/_rolldown/runtime.mjs +7 -0
- package/build/address.d.ts +1 -1
- 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.d.ts +1 -1
- package/build/builder.js +58 -62
- package/build/builder.js.map +1 -1
- package/build/builder.mjs +60 -0
- package/build/builder.mjs.map +1 -0
- package/build/conf/index.d.ts +1 -1
- package/build/conf/index.js +9 -11
- package/build/conf/index.js.map +1 -1
- package/build/conf/index.mjs +10 -0
- package/build/conf/index.mjs.map +1 -0
- package/build/config-path.js +152 -163
- package/build/config-path.js.map +1 -1
- package/build/config-path.mjs +169 -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.d.ts +1 -1
- package/build/config.js +170 -201
- package/build/config.js.map +1 -1
- package/build/config.mjs +171 -0
- package/build/config.mjs.map +1 -0
- package/build/index.js +52 -167
- package/build/index.mjs +14 -0
- package/build/package-access.d.ts +1 -1
- 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.d.ts +1 -1
- package/build/parse.js +80 -99
- package/build/parse.js.map +1 -1
- package/build/parse.mjs +83 -0
- package/build/parse.mjs.map +1 -0
- package/build/security.d.ts +1 -1
- 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 +11 -13
- package/build/token.js.map +1 -1
- package/build/token.mjs +13 -0
- package/build/token.mjs.map +1 -0
- package/build/uplinks.d.ts +1 -1
- 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.d.ts +1 -1
- 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 +18 -7
- 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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
|
|
3
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
4
|
+
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
5
|
+
});
|
|
6
|
+
//#endregion
|
|
7
|
+
export { __require };
|
package/build/address.d.ts
CHANGED
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,2BAA2B;;;;;;;;;;;;;;;AAuBrD,SAAgB,aAAa,YAA0C;CAKrE,MAAM,aAAa,8DAA8D,KAAK,WAAW;AAEjG,KAAI,WACF,QAAO;EACL,OAAO,WAAW,MAAM,gBAAA;EACxB,MAAM,WAAW,MAAM,WAAW,MAAM,gBAAA;EACxC,MAAM,WAAW,MAAM,gBAAA;EACxB;CAGH,MAAM,cAAc,kCAAkC,KAAK,WAAW;AACtE,KAAI,CAAC,YAGH,QAAO;AAGT,QAAO;EACL,MAAM,YAAY;EAClB,OAAO,YAAY,MAAM;EACzB,MAAM,YAAY;EACnB;;AAGH,SAAS,aAAa,GAA0B;AAC9C,QAAO,EAAE,UAAU,SAAS,QAAQ,EAAE,SAAS,GAAG,EAAE,MAAM,KAAK,EAAE,KAAK,GAAG,EAAE;;;;;;;;;;;;;AAc7E,SAAgB,iBACd,QACA,QACe;AACf,SAAM,mCAAmC,OAAO;AAEhD,KAAI,CAAC,QAAQ;AACX,UAAM,4CAA4C;AAClD,SAAO;GAAE,OAAO,gBAAA;GAAkB,MAAM,gBAAA;GAAgB,MAAM,gBAAA;GAAc;;AAG9E,KAAI,MAAM,QAAQ,OAAO,EAAE;EACzB,MAAM,iBAAiB,OAAO,QAAQ,SAAS,OAAO,SAAS,SAAS;AAExE,MAAI,eAAe,WAAW,EAC5B,OAAM,IAAI,MAAM,yCAAyC;EAG3D,MAAM,UAAoB,EAAE;EAC5B,MAAM,QAAyB,EAAE;AAEjC,OAAK,MAAM,OAAO,gBAAgB;GAChC,MAAM,YAAY,aAAa,IAAc;AAC7C,OAAI,WAAW;AACb,YAAM,kCAAkC,UAAU;AAClD,UAAM,KAAK,UAAU;UAChB;AACL,YAAM,6BAA6B,IAAI;AACvC,YAAQ,KAAK,IAAc;;;AAI/B,UAAQ,SAAS,QACf,OAAO,KACL,EAAE,MAAM,KAAK,EACb,oKAGD,CACF;AAED,MAAI,MAAM,WAAW,EACnB,OAAM,IAAI,MAAM,yDAAyD;EAG3E,MAAM,aAAa,MAAM;AAEzB,MAAI,OAAO,SAAS,EAClB,QAAO,KACL,0EAA0E,aACxE,WACD,GACF;AAGH,SAAO;;CAGT,MAAM,SAAS,aAAa,OAAiB;AAC7C,KAAI,CAAC,OACH,OAAM,IAAI,MACR,qBAAqB,OAAO,oIAG7B;AAEH,QAAO"}
|
|
@@ -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,2BAA2B;;;;;;;;;;;;;;;AAuBrD,SAAgB,aAAa,YAA0C;CAKrE,MAAM,aAAa,8DAA8D,KAAK,WAAW;AAEjG,KAAI,WACF,QAAO;EACL,OAAO,WAAW,MAAM;EACxB,MAAM,WAAW,MAAM,WAAW,MAAM;EACxC,MAAM,WAAW,MAAM;EACxB;CAGH,MAAM,cAAc,kCAAkC,KAAK,WAAW;AACtE,KAAI,CAAC,YAGH,QAAO;AAGT,QAAO;EACL,MAAM,YAAY;EAClB,OAAO,YAAY,MAAM;EACzB,MAAM,YAAY;EACnB;;AAGH,SAAS,aAAa,GAA0B;AAC9C,QAAO,EAAE,UAAU,SAAS,QAAQ,EAAE,SAAS,GAAG,EAAE,MAAM,KAAK,EAAE,KAAK,GAAG,EAAE;;;;;;;;;;;;;AAc7E,SAAgB,iBACd,QACA,QACe;AACf,OAAM,mCAAmC,OAAO;AAEhD,KAAI,CAAC,QAAQ;AACX,QAAM,4CAA4C;AAClD,SAAO;GAAE,OAAO;GAAkB,MAAM;GAAgB,MAAM;GAAc;;AAG9E,KAAI,MAAM,QAAQ,OAAO,EAAE;EACzB,MAAM,iBAAiB,OAAO,QAAQ,SAAS,OAAO,SAAS,SAAS;AAExE,MAAI,eAAe,WAAW,EAC5B,OAAM,IAAI,MAAM,yCAAyC;EAG3D,MAAM,UAAoB,EAAE;EAC5B,MAAM,QAAyB,EAAE;AAEjC,OAAK,MAAM,OAAO,gBAAgB;GAChC,MAAM,YAAY,aAAa,IAAc;AAC7C,OAAI,WAAW;AACb,UAAM,kCAAkC,UAAU;AAClD,UAAM,KAAK,UAAU;UAChB;AACL,UAAM,6BAA6B,IAAI;AACvC,YAAQ,KAAK,IAAc;;;AAI/B,UAAQ,SAAS,QACf,OAAO,KACL,EAAE,MAAM,KAAK,EACb,oKAGD,CACF;AAED,MAAI,MAAM,WAAW,EACnB,OAAM,IAAI,MAAM,yDAAyD;EAG3E,MAAM,aAAa,MAAM;AAEzB,MAAI,OAAO,SAAS,EAClB,QAAO,KACL,0EAA0E,aACxE,WACD,GACF;AAGH,SAAO;;CAGT,MAAM,SAAS,aAAa,OAAiB;AAC7C,KAAI,CAAC,OACH,OAAM,IAAI,MACR,qBAAqB,OAAO,oIAG7B;AAEH,QAAO"}
|
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;AACR,KAAI,oBAAoB,KACtB,QAAO,GAAG,KAAK,GAAG;UACT,OAAA,QAAE,SAAS,gBAAgB,IAAI,OAAA,QAAE,QAAQ,gBAAgB,KAAK,MACvE,QAAO;UACE,oBAAoB,MAC7B,QAAO;AAGT,QAAO,GAAG,KAAK,GAAG"}
|
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;AACR,KAAI,oBAAoB,KACtB,QAAO,GAAG,KAAK,GAAG;UACT,EAAE,SAAS,gBAAgB,IAAI,EAAE,QAAQ,gBAAgB,KAAK,MACvE,QAAO;UACE,oBAAoB,MAC7B,QAAO;AAGT,QAAO,GAAG,KAAK,GAAG"}
|
package/build/builder.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AuthConf, ConfigYaml, LoggerConfigItem, PackageAccessYaml, Security, ServerSettingsConf, UpLinkConf } from '@verdaccio/types';
|
|
2
2
|
/**
|
|
3
3
|
* Helper configuration builder constructor, used to build the configuration for testing or
|
|
4
4
|
* programatically creating a configuration.
|
package/build/builder.js
CHANGED
|
@@ -1,65 +1,61 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _lodash = require("lodash");
|
|
8
|
-
var _ = require(".");
|
|
1
|
+
require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_parse = require("./parse.js");
|
|
3
|
+
require("./index.js");
|
|
4
|
+
let lodash = require("lodash");
|
|
5
|
+
//#region src/builder.ts
|
|
9
6
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class ConfigBuilder {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
}
|
|
7
|
+
* Helper configuration builder constructor, used to build the configuration for testing or
|
|
8
|
+
* programatically creating a configuration.
|
|
9
|
+
*/
|
|
10
|
+
var ConfigBuilder = class ConfigBuilder {
|
|
11
|
+
config;
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.config = (0, lodash.merge)(config, {
|
|
14
|
+
uplinks: {},
|
|
15
|
+
packages: {},
|
|
16
|
+
security: {}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
static build(config) {
|
|
20
|
+
return new ConfigBuilder(config);
|
|
21
|
+
}
|
|
22
|
+
addPackageAccess(pattern, pkgAccess) {
|
|
23
|
+
this.config.packages[pattern] = pkgAccess;
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
addUplink(id, uplink) {
|
|
27
|
+
this.config.uplinks[id] = uplink;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
addSecurity(security) {
|
|
31
|
+
this.config.security = (0, lodash.merge)(this.config.security, security);
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
addAuth(auth) {
|
|
35
|
+
this.config.auth = (0, lodash.merge)(this.config.auth, auth);
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
addLogger(log) {
|
|
39
|
+
this.config.log = log;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
addServer(server) {
|
|
43
|
+
this.config.server = (0, lodash.merge)(this.config.server, server);
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
addStorage(storage) {
|
|
47
|
+
if (typeof storage === "string") this.config.storage = storage;
|
|
48
|
+
else this.config.store = storage;
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
getConfig() {
|
|
52
|
+
return this.config;
|
|
53
|
+
}
|
|
54
|
+
getAsYaml() {
|
|
55
|
+
return require_parse.fromJStoYAML(this.config);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
64
59
|
exports.default = ConfigBuilder;
|
|
60
|
+
|
|
65
61
|
//# sourceMappingURL=builder.js.map
|
package/build/builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","names":[
|
|
1
|
+
{"version":3,"file":"builder.js","names":[],"sources":["../src/builder.ts"],"sourcesContent":["import { merge } from 'lodash';\n\nimport type {\n AuthConf,\n ConfigYaml,\n LoggerConfigItem,\n PackageAccessYaml,\n Security,\n ServerSettingsConf,\n UpLinkConf,\n} from '@verdaccio/types';\n\nimport { fromJStoYAML } from '.';\n\n/**\n * Helper configuration builder constructor, used to build the configuration for testing or\n * programatically creating a configuration.\n */\nexport default class ConfigBuilder {\n private config: ConfigYaml;\n\n public constructor(config?: Partial<ConfigYaml>) {\n this.config = merge(config, { uplinks: {}, packages: {}, security: {} });\n }\n\n public static build(config?: Partial<ConfigYaml>): ConfigBuilder {\n return new ConfigBuilder(config);\n }\n\n public addPackageAccess(pattern: string, pkgAccess: PackageAccessYaml) {\n // @ts-ignore\n this.config.packages[pattern] = pkgAccess;\n return this;\n }\n\n public addUplink(id: string, uplink: UpLinkConf) {\n this.config.uplinks[id] = uplink;\n return this;\n }\n\n public addSecurity(security: Partial<Security>) {\n this.config.security = merge(this.config.security, security);\n return this;\n }\n\n public addAuth(auth: Partial<AuthConf>) {\n this.config.auth = merge(this.config.auth, auth);\n return this;\n }\n\n public addLogger(log: LoggerConfigItem) {\n this.config.log = log;\n return this;\n }\n\n public addServer(server: Partial<ServerSettingsConf>) {\n this.config.server = merge(this.config.server, server);\n return this;\n }\n\n public addStorage(storage: string | object) {\n if (typeof storage === 'string') {\n this.config.storage = storage;\n } else {\n this.config.store = storage;\n }\n return this;\n }\n\n public getConfig(): ConfigYaml {\n return this.config;\n }\n\n public getAsYaml(): string {\n return fromJStoYAML(this.config) as string;\n }\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAqB,gBAArB,MAAqB,cAAc;CACjC;CAEA,YAAmB,QAA8B;AAC/C,OAAK,UAAA,GAAA,OAAA,OAAe,QAAQ;GAAE,SAAS,EAAE;GAAE,UAAU,EAAE;GAAE,UAAU,EAAE;GAAE,CAAC;;CAG1E,OAAc,MAAM,QAA6C;AAC/D,SAAO,IAAI,cAAc,OAAO;;CAGlC,iBAAwB,SAAiB,WAA8B;AAErE,OAAK,OAAO,SAAS,WAAW;AAChC,SAAO;;CAGT,UAAiB,IAAY,QAAoB;AAC/C,OAAK,OAAO,QAAQ,MAAM;AAC1B,SAAO;;CAGT,YAAmB,UAA6B;AAC9C,OAAK,OAAO,YAAA,GAAA,OAAA,OAAiB,KAAK,OAAO,UAAU,SAAS;AAC5D,SAAO;;CAGT,QAAe,MAAyB;AACtC,OAAK,OAAO,QAAA,GAAA,OAAA,OAAa,KAAK,OAAO,MAAM,KAAK;AAChD,SAAO;;CAGT,UAAiB,KAAuB;AACtC,OAAK,OAAO,MAAM;AAClB,SAAO;;CAGT,UAAiB,QAAqC;AACpD,OAAK,OAAO,UAAA,GAAA,OAAA,OAAe,KAAK,OAAO,QAAQ,OAAO;AACtD,SAAO;;CAGT,WAAkB,SAA0B;AAC1C,MAAI,OAAO,YAAY,SACrB,MAAK,OAAO,UAAU;MAEtB,MAAK,OAAO,QAAQ;AAEtB,SAAO;;CAGT,YAA+B;AAC7B,SAAO,KAAK;;CAGd,YAA2B;AACzB,SAAO,cAAA,aAAa,KAAK,OAAO"}
|