@verdaccio/url 13.0.5 → 13.1.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.
@@ -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/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { IncomingHttpHeaders } from 'node:http';
3
2
  /**
4
3
  * Check if URI is starting with "http://", "https://" or "//"
package/build/index.js CHANGED
@@ -1,126 +1,103 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
5
4
  });
6
- exports.combineBaseUrl = combineBaseUrl;
7
- exports.getPublicUrl = getPublicUrl;
8
- exports.getWebProtocol = getWebProtocol;
9
- exports.isHost = isHost;
10
- exports.isURL = void 0;
11
- exports.isURLhasValidProtocol = isURLhasValidProtocol;
12
- exports.validateURL = validateURL;
13
- exports.wrapPrefix = wrapPrefix;
14
- var _debug = _interopRequireDefault(require("debug"));
15
- var _nodeUrl = require("node:url");
16
- var _validator = _interopRequireDefault(require("validator"));
17
- var _core = require("@verdaccio/core");
18
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
- const debug = (0, _debug.default)('verdaccio:core:url');
20
- const validProtocols = ['https', 'http'];
21
-
5
+ const require_runtime = require("./_virtual/_rolldown/runtime.js");
6
+ let debug = require("debug");
7
+ debug = require_runtime.__toESM(debug);
8
+ let node_url = require("node:url");
9
+ let validator = require("validator");
10
+ validator = require_runtime.__toESM(validator);
11
+ let _verdaccio_core = require("@verdaccio/core");
12
+ //#region src/index.ts
13
+ var debug$1 = (0, debug.default)("verdaccio:core:url");
14
+ var validProtocols = ["https", "http"];
22
15
  /**
23
- * Check if URI is starting with "http://", "https://" or "//"
24
- * @param {string} uri
25
- */
16
+ * Check if URI is starting with "http://", "https://" or "//"
17
+ * @param {string} uri
18
+ */
26
19
  function isURLhasValidProtocol(uri) {
27
- return /^(https?:)?\/\//.test(uri);
20
+ return /^(https?:)?\/\//.test(uri);
28
21
  }
29
- function isHost(url = '', options = {}) {
30
- return _validator.default.isURL(url, {
31
- require_host: true,
32
- allow_trailing_dot: false,
33
- require_valid_protocol: false,
34
- // @ts-ignore
35
- require_port: false,
36
- require_tld: false,
37
- ...options
38
- });
22
+ function isHost(url = "", options = {}) {
23
+ return validator.default.isURL(url, {
24
+ require_host: true,
25
+ allow_trailing_dot: false,
26
+ require_valid_protocol: false,
27
+ require_port: false,
28
+ require_tld: false,
29
+ ...options
30
+ });
39
31
  }
40
-
41
32
  /**
42
- * Detect running protocol (http or https)
43
- */
33
+ * Detect running protocol (http or https)
34
+ */
44
35
  function getWebProtocol(headerProtocol, protocol) {
45
- let returnProtocol;
46
- const [, defaultProtocol] = validProtocols;
47
- // HAProxy variant might return http,http with X-Forwarded-Proto
48
- if (typeof headerProtocol === 'string' && headerProtocol !== '') {
49
- debug('header protocol: %o', protocol);
50
- const commaIndex = headerProtocol.indexOf(',');
51
- returnProtocol = commaIndex > 0 ? headerProtocol.slice(0, commaIndex) : headerProtocol;
52
- } else {
53
- debug('req protocol: %o', headerProtocol);
54
- returnProtocol = protocol;
55
- }
56
- return validProtocols.includes(returnProtocol) ? returnProtocol : defaultProtocol;
36
+ let returnProtocol;
37
+ const [, defaultProtocol] = validProtocols;
38
+ if (typeof headerProtocol === "string" && headerProtocol !== "") {
39
+ debug$1("header protocol: %o", protocol);
40
+ const commaIndex = headerProtocol.indexOf(",");
41
+ returnProtocol = commaIndex > 0 ? headerProtocol.slice(0, commaIndex) : headerProtocol;
42
+ } else {
43
+ debug$1("req protocol: %o", headerProtocol);
44
+ returnProtocol = protocol;
45
+ }
46
+ return validProtocols.includes(returnProtocol) ? returnProtocol : defaultProtocol;
57
47
  }
58
48
  function wrapPrefix(prefix) {
59
- if (prefix === '' || typeof prefix === 'undefined' || prefix === null) {
60
- return '';
61
- } else if (!prefix.startsWith('/') && prefix.endsWith('/')) {
62
- return `/${prefix}`;
63
- } else if (!prefix.startsWith('/') && !prefix.endsWith('/')) {
64
- return `/${prefix}/`;
65
- } else if (prefix.startsWith('/') && !prefix.endsWith('/')) {
66
- return `${prefix}/`;
67
- } else {
68
- return prefix;
69
- }
49
+ if (prefix === "" || typeof prefix === "undefined" || prefix === null) return "";
50
+ else if (!prefix.startsWith("/") && prefix.endsWith("/")) return `/${prefix}`;
51
+ else if (!prefix.startsWith("/") && !prefix.endsWith("/")) return `/${prefix}/`;
52
+ else if (prefix.startsWith("/") && !prefix.endsWith("/")) return `${prefix}/`;
53
+ else return prefix;
70
54
  }
71
-
72
55
  /**
73
- * Create base url for registry.
74
- * @return {String} base registry url
75
- */
76
- function combineBaseUrl(protocol, host, prefix = '') {
77
- debug('combined protocol %o', protocol);
78
- debug('combined host %o', host);
79
- const newPrefix = wrapPrefix(prefix);
80
- debug('combined prefix %o', newPrefix);
81
- const groupedURI = new _nodeUrl.URL(wrapPrefix(prefix), `${protocol}://${host}`);
82
- const result = groupedURI.href;
83
- debug('combined url %o', result);
84
- return result;
56
+ * Create base url for registry.
57
+ * @return {String} base registry url
58
+ */
59
+ function combineBaseUrl(protocol, host, prefix = "") {
60
+ debug$1("combined protocol %o", protocol);
61
+ debug$1("combined host %o", host);
62
+ debug$1("combined prefix %o", wrapPrefix(prefix));
63
+ const result = new node_url.URL(wrapPrefix(prefix), `${protocol}://${host}`).href;
64
+ debug$1("combined url %o", result);
65
+ return result;
85
66
  }
86
67
  function validateURL(publicUrl) {
87
- try {
88
- const parsed = new _nodeUrl.URL(publicUrl);
89
- if (!validProtocols.includes(parsed.protocol.replace(':', ''))) {
90
- throw Error('invalid protocol');
91
- }
92
- return true;
93
- } catch {
94
- // TODO: add error logger here
95
- return false;
96
- }
68
+ try {
69
+ const parsed = new node_url.URL(publicUrl);
70
+ if (!validProtocols.includes(parsed.protocol.replace(":", ""))) throw Error("invalid protocol");
71
+ return true;
72
+ } catch {
73
+ return false;
74
+ }
97
75
  }
98
- function getPublicUrl(url_prefix = '', requestOptions) {
99
- if (validateURL(process.env.VERDACCIO_PUBLIC_URL)) {
100
- const envURL = new _nodeUrl.URL(wrapPrefix(url_prefix), process.env.VERDACCIO_PUBLIC_URL).href;
101
- debug('public url by env %o', envURL);
102
- return envURL;
103
- } else if (requestOptions.headers['host']) {
104
- const host = requestOptions.headers['host'];
105
- if (!isHost(host)) {
106
- throw new Error('invalid host');
107
- }
108
-
109
- // 'X-Forwarded-Proto' is the default header
110
- const protoHeader = process.env.VERDACCIO_FORWARDED_PROTO?.toLocaleLowerCase() ?? _core.HEADERS.FORWARDED_PROTO.toLowerCase();
111
- const forwardedProtocolHeaderValue = requestOptions.headers[protoHeader];
112
- if (Array.isArray(forwardedProtocolHeaderValue)) {
113
- // This really should never happen - only set-cookie is allowed to have
114
- // multiple values.
115
- throw new Error('invalid forwarded protocol header value. Reading header ' + protoHeader);
116
- }
117
- const protocol = getWebProtocol(forwardedProtocolHeaderValue, requestOptions.protocol);
118
- const combinedUrl = combineBaseUrl(protocol, host, url_prefix);
119
- debug('public url by request %o', combinedUrl);
120
- return combinedUrl;
121
- } else {
122
- return '/';
123
- }
76
+ function getPublicUrl(url_prefix = "", requestOptions) {
77
+ if (validateURL(process.env.VERDACCIO_PUBLIC_URL)) {
78
+ const envURL = new node_url.URL(wrapPrefix(url_prefix), process.env.VERDACCIO_PUBLIC_URL).href;
79
+ debug$1("public url by env %o", envURL);
80
+ return envURL;
81
+ } else if (requestOptions.headers["host"]) {
82
+ const host = requestOptions.headers["host"];
83
+ if (!isHost(host)) throw new Error("invalid host");
84
+ const protoHeader = process.env.VERDACCIO_FORWARDED_PROTO?.toLocaleLowerCase() ?? _verdaccio_core.HEADERS.FORWARDED_PROTO.toLowerCase();
85
+ const forwardedProtocolHeaderValue = requestOptions.headers[protoHeader];
86
+ if (Array.isArray(forwardedProtocolHeaderValue)) throw new Error("invalid forwarded protocol header value. Reading header " + protoHeader);
87
+ const combinedUrl = combineBaseUrl(getWebProtocol(forwardedProtocolHeaderValue, requestOptions.protocol), host, url_prefix);
88
+ debug$1("public url by request %o", combinedUrl);
89
+ return combinedUrl;
90
+ } else return "/";
124
91
  }
125
- const isURL = exports.isURL = _validator.default.isURL;
92
+ var isURL = validator.default.isURL;
93
+ //#endregion
94
+ exports.combineBaseUrl = combineBaseUrl;
95
+ exports.getPublicUrl = getPublicUrl;
96
+ exports.getWebProtocol = getWebProtocol;
97
+ exports.isHost = isHost;
98
+ exports.isURL = isURL;
99
+ exports.isURLhasValidProtocol = isURLhasValidProtocol;
100
+ exports.validateURL = validateURL;
101
+ exports.wrapPrefix = wrapPrefix;
102
+
126
103
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_debug","_interopRequireDefault","require","_nodeUrl","_validator","_core","e","__esModule","default","debug","buildDebug","validProtocols","isURLhasValidProtocol","uri","test","isHost","url","options","validator","isURL","require_host","allow_trailing_dot","require_valid_protocol","require_port","require_tld","getWebProtocol","headerProtocol","protocol","returnProtocol","defaultProtocol","commaIndex","indexOf","slice","includes","wrapPrefix","prefix","startsWith","endsWith","combineBaseUrl","host","newPrefix","groupedURI","URL","result","href","validateURL","publicUrl","parsed","replace","Error","getPublicUrl","url_prefix","requestOptions","process","env","VERDACCIO_PUBLIC_URL","envURL","headers","protoHeader","VERDACCIO_FORWARDED_PROTO","toLocaleLowerCase","HEADERS","FORWARDED_PROTO","toLowerCase","forwardedProtocolHeaderValue","Array","isArray","combinedUrl","exports"],"sources":["../src/index.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { IncomingHttpHeaders } from 'node:http';\nimport { URL } from 'node:url';\nimport validator from 'validator';\n\nimport { HEADERS } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:core:url');\n\nconst validProtocols = ['https', 'http'];\n\n/**\n * Check if URI is starting with \"http://\", \"https://\" or \"//\"\n * @param {string} uri\n */\nexport function isURLhasValidProtocol(uri: string): boolean {\n return /^(https?:)?\\/\\//.test(uri);\n}\n\nexport function isHost(url: string = '', options = {}): boolean {\n return validator.isURL(url, {\n require_host: true,\n allow_trailing_dot: false,\n require_valid_protocol: false,\n // @ts-ignore\n require_port: false,\n require_tld: false,\n ...options,\n });\n}\n\n/**\n * Detect running protocol (http or https)\n */\nexport function getWebProtocol(headerProtocol: string | undefined, protocol: string): string {\n let returnProtocol;\n const [, defaultProtocol] = validProtocols;\n // HAProxy variant might return http,http with X-Forwarded-Proto\n if (typeof headerProtocol === 'string' && headerProtocol !== '') {\n debug('header protocol: %o', protocol);\n const commaIndex = headerProtocol.indexOf(',');\n returnProtocol = commaIndex > 0 ? headerProtocol.slice(0, commaIndex) : headerProtocol;\n } else {\n debug('req protocol: %o', headerProtocol);\n returnProtocol = protocol;\n }\n\n return validProtocols.includes(returnProtocol) ? returnProtocol : defaultProtocol;\n}\n\nexport function wrapPrefix(prefix: string | void): string {\n if (prefix === '' || typeof prefix === 'undefined' || prefix === null) {\n return '';\n } else if (!prefix.startsWith('/') && prefix.endsWith('/')) {\n return `/${prefix}`;\n } else if (!prefix.startsWith('/') && !prefix.endsWith('/')) {\n return `/${prefix}/`;\n } else if (prefix.startsWith('/') && !prefix.endsWith('/')) {\n return `${prefix}/`;\n } else {\n return prefix;\n }\n}\n\n/**\n * Create base url for registry.\n * @return {String} base registry url\n */\nexport function combineBaseUrl(protocol: string, host: string, prefix: string = ''): string {\n debug('combined protocol %o', protocol);\n debug('combined host %o', host);\n const newPrefix = wrapPrefix(prefix);\n debug('combined prefix %o', newPrefix);\n const groupedURI = new URL(wrapPrefix(prefix), `${protocol}://${host}`);\n const result = groupedURI.href;\n debug('combined url %o', result);\n return result;\n}\n\nexport function validateURL(publicUrl: string | void) {\n try {\n const parsed = new URL(publicUrl as string);\n if (!validProtocols.includes(parsed.protocol.replace(':', ''))) {\n throw Error('invalid protocol');\n }\n return true;\n } catch {\n // TODO: add error logger here\n return false;\n }\n}\n\nexport type RequestOptions = {\n /**\n * Request host (without port in Express 4).\n */\n host: string;\n /**\n * Request protocol, usually http or https.\n */\n protocol: string;\n /**\n * Request headers.\n */\n headers: IncomingHttpHeaders;\n /**\n * Request remote address. This is the IPv4 or IPv6 address of the client.\n */\n remoteAddress?: string;\n /**\n * Logged username the request, usually after token verification.\n */\n username?: string;\n};\n\nexport function getPublicUrl(url_prefix: string = '', requestOptions: RequestOptions): string {\n if (validateURL(process.env.VERDACCIO_PUBLIC_URL as string)) {\n const envURL = new URL(wrapPrefix(url_prefix), process.env.VERDACCIO_PUBLIC_URL as string).href;\n debug('public url by env %o', envURL);\n return envURL;\n } else if (requestOptions.headers['host']) {\n const host = requestOptions.headers['host'];\n if (!isHost(host)) {\n throw new Error('invalid host');\n }\n\n // 'X-Forwarded-Proto' is the default header\n const protoHeader: string =\n process.env.VERDACCIO_FORWARDED_PROTO?.toLocaleLowerCase() ??\n HEADERS.FORWARDED_PROTO.toLowerCase();\n const forwardedProtocolHeaderValue = requestOptions.headers[protoHeader];\n\n if (Array.isArray(forwardedProtocolHeaderValue)) {\n // This really should never happen - only set-cookie is allowed to have\n // multiple values.\n throw new Error('invalid forwarded protocol header value. Reading header ' + protoHeader);\n }\n\n const protocol = getWebProtocol(forwardedProtocolHeaderValue, requestOptions.protocol);\n const combinedUrl = combineBaseUrl(protocol, host, url_prefix);\n debug('public url by request %o', combinedUrl);\n return combinedUrl;\n } else {\n return '/';\n }\n}\n\nexport const isURL = validator.isURL;\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AAA0C,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1C,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,oBAAoB,CAAC;AAE9C,MAAMC,cAAc,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC;;AAExC;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CAACC,GAAW,EAAW;EAC1D,OAAO,iBAAiB,CAACC,IAAI,CAACD,GAAG,CAAC;AACpC;AAEO,SAASE,MAAMA,CAACC,GAAW,GAAG,EAAE,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAW;EAC9D,OAAOC,kBAAS,CAACC,KAAK,CAACH,GAAG,EAAE;IAC1BI,YAAY,EAAE,IAAI;IAClBC,kBAAkB,EAAE,KAAK;IACzBC,sBAAsB,EAAE,KAAK;IAC7B;IACAC,YAAY,EAAE,KAAK;IACnBC,WAAW,EAAE,KAAK;IAClB,GAAGP;EACL,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACO,SAASQ,cAAcA,CAACC,cAAkC,EAAEC,QAAgB,EAAU;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AC,MAAM,CAAC,EAAE;IACzC,MAAMlB,IAAI,GAAGa,cAAc,CAACK,OAAO,CAAC,MAAM,CAAC;IAC3C,IAAI,CAAC1C,MAAM,CAACwB,IAAI,CAAC,EAAE;MACjB,MAAM,IAAIU,KAAK,CAAC,cAAc,CAAC;IACjC;;IAEA;IACA,MAAMS,WAAmB,GACvBL,OAAO,CAACC,GAAG,CAACK,yBAAyB,EAAEC,iBAAiB,CAAC,CAAC,IAC1DC,aAAO,CAACC,eAAe,CAACC,WAAW,CAAC,CAAC;IACvC,MAAMC,4BAA4B,GAAGZ,cAAc,CAACK,OAAO,CAACC,WAAW,CAAC;IAExE,IAAIO,KAAK,CAACC,OAAO,CAACF,4BAA4B,CAAC,EAAE;MAC/C;MACA;MACA,MAAM,IAAIf,KAAK,CAAC,0DAA0D,GAAGS,WAAW,CAAC;IAC3F;IAEA,MAAM/B,QAAQ,GAAGF,cAAc,CAACuC,4BAA4B,EAAEZ,cAAc,CAACzB,QAAQ,CAAC;IACtF,MAAMwC,WAAW,GAAG7B,cAAc,CAACX,QAAQ,EAAEY,IAAI,EAAEY,UAAU,CAAC;IAC9D1C,KAAK,CAAC,0BAA0B,EAAE0D,WAAW,CAAC;IAC9C,OAAOA,WAAW;EACpB,CAAC,MAAM;IACL,OAAO,GAAG;EACZ;AACF;AAEO,MAAMhD,KAAK,GAAAiD,OAAA,CAAAjD,KAAA,GAAGD,kBAAS,CAACC,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { IncomingHttpHeaders } from 'node:http';\nimport { URL } from 'node:url';\nimport validator from 'validator';\n\nimport { HEADERS } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:core:url');\n\nconst validProtocols = ['https', 'http'];\n\n/**\n * Check if URI is starting with \"http://\", \"https://\" or \"//\"\n * @param {string} uri\n */\nexport function isURLhasValidProtocol(uri: string): boolean {\n return /^(https?:)?\\/\\//.test(uri);\n}\n\nexport function isHost(url: string = '', options = {}): boolean {\n return validator.isURL(url, {\n require_host: true,\n allow_trailing_dot: false,\n require_valid_protocol: false,\n // @ts-ignore\n require_port: false,\n require_tld: false,\n ...options,\n });\n}\n\n/**\n * Detect running protocol (http or https)\n */\nexport function getWebProtocol(headerProtocol: string | undefined, protocol: string): string {\n let returnProtocol;\n const [, defaultProtocol] = validProtocols;\n // HAProxy variant might return http,http with X-Forwarded-Proto\n if (typeof headerProtocol === 'string' && headerProtocol !== '') {\n debug('header protocol: %o', protocol);\n const commaIndex = headerProtocol.indexOf(',');\n returnProtocol = commaIndex > 0 ? headerProtocol.slice(0, commaIndex) : headerProtocol;\n } else {\n debug('req protocol: %o', headerProtocol);\n returnProtocol = protocol;\n }\n\n return validProtocols.includes(returnProtocol) ? returnProtocol : defaultProtocol;\n}\n\nexport function wrapPrefix(prefix: string | void): string {\n if (prefix === '' || typeof prefix === 'undefined' || prefix === null) {\n return '';\n } else if (!prefix.startsWith('/') && prefix.endsWith('/')) {\n return `/${prefix}`;\n } else if (!prefix.startsWith('/') && !prefix.endsWith('/')) {\n return `/${prefix}/`;\n } else if (prefix.startsWith('/') && !prefix.endsWith('/')) {\n return `${prefix}/`;\n } else {\n return prefix;\n }\n}\n\n/**\n * Create base url for registry.\n * @return {String} base registry url\n */\nexport function combineBaseUrl(protocol: string, host: string, prefix: string = ''): string {\n debug('combined protocol %o', protocol);\n debug('combined host %o', host);\n const newPrefix = wrapPrefix(prefix);\n debug('combined prefix %o', newPrefix);\n const groupedURI = new URL(wrapPrefix(prefix), `${protocol}://${host}`);\n const result = groupedURI.href;\n debug('combined url %o', result);\n return result;\n}\n\nexport function validateURL(publicUrl: string | void) {\n try {\n const parsed = new URL(publicUrl as string);\n if (!validProtocols.includes(parsed.protocol.replace(':', ''))) {\n throw Error('invalid protocol');\n }\n return true;\n } catch {\n // TODO: add error logger here\n return false;\n }\n}\n\nexport type RequestOptions = {\n /**\n * Request host (without port in Express 4).\n */\n host: string;\n /**\n * Request protocol, usually http or https.\n */\n protocol: string;\n /**\n * Request headers.\n */\n headers: IncomingHttpHeaders;\n /**\n * Request remote address. This is the IPv4 or IPv6 address of the client.\n */\n remoteAddress?: string;\n /**\n * Logged username the request, usually after token verification.\n */\n username?: string;\n};\n\nexport function getPublicUrl(url_prefix: string = '', requestOptions: RequestOptions): string {\n if (validateURL(process.env.VERDACCIO_PUBLIC_URL as string)) {\n const envURL = new URL(wrapPrefix(url_prefix), process.env.VERDACCIO_PUBLIC_URL as string).href;\n debug('public url by env %o', envURL);\n return envURL;\n } else if (requestOptions.headers['host']) {\n const host = requestOptions.headers['host'];\n if (!isHost(host)) {\n throw new Error('invalid host');\n }\n\n // 'X-Forwarded-Proto' is the default header\n const protoHeader: string =\n process.env.VERDACCIO_FORWARDED_PROTO?.toLocaleLowerCase() ??\n HEADERS.FORWARDED_PROTO.toLowerCase();\n const forwardedProtocolHeaderValue = requestOptions.headers[protoHeader];\n\n if (Array.isArray(forwardedProtocolHeaderValue)) {\n // This really should never happen - only set-cookie is allowed to have\n // multiple values.\n throw new Error('invalid forwarded protocol header value. Reading header ' + protoHeader);\n }\n\n const protocol = getWebProtocol(forwardedProtocolHeaderValue, requestOptions.protocol);\n const combinedUrl = combineBaseUrl(protocol, host, url_prefix);\n debug('public url by request %o', combinedUrl);\n return combinedUrl;\n } else {\n return '/';\n }\n}\n\nexport const isURL = validator.isURL;\n"],"mappings":";;;;;;;;;;;;AAOA,IAAM,WAAA,GAAA,MAAA,SAAmB,oBAAoB;AAE7C,IAAM,iBAAiB,CAAC,SAAS,MAAM;;;;;AAMvC,SAAgB,sBAAsB,KAAsB;CAC1D,OAAO,kBAAkB,KAAK,GAAG;AACnC;AAEA,SAAgB,OAAO,MAAc,IAAI,UAAU,CAAC,GAAY;CAC9D,OAAO,UAAA,QAAU,MAAM,KAAK;EAC1B,cAAc;EACd,oBAAoB;EACpB,wBAAwB;EAExB,cAAc;EACd,aAAa;EACb,GAAG;CACL,CAAC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aAAa,aAAqB,IAAI,gBAAwC;CAC5F,IAAI,YAAY,QAAQ,IAAI,oBAA8B,GAAG;EAC3D,MAAM,SAAS,IAAI,SAAA,IAAI,WAAW,UAAU,GAAG,QAAQ,IAAI,oBAA8B,EAAE;EAC3F,QAAM,wBAAwB,MAAM;EACpC,OAAO;CACT,OAAO,IAAI,eAAe,QAAQ,SAAS;EACzC,MAAM,OAAO,eAAe,QAAQ;EACpC,IAAI,CAAC,OAAO,IAAI,GACd,MAAM,IAAI,MAAM,cAAc;EAIhC,MAAM,cACJ,QAAQ,IAAI,2BAA2B,kBAAkB,KACzD,gBAAA,QAAQ,gBAAgB,YAAY;EACtC,MAAM,+BAA+B,eAAe,QAAQ;EAE5D,IAAI,MAAM,QAAQ,4BAA4B,GAG5C,MAAM,IAAI,MAAM,6DAA6D,WAAW;EAI1F,MAAM,cAAc,eADH,eAAe,8BAA8B,eAAe,QAC1C,GAAU,MAAM,UAAU;EAC7D,QAAM,4BAA4B,WAAW;EAC7C,OAAO;CACT,OACE,OAAO;AAEX;AAEA,IAAa,QAAQ,UAAA,QAAU"}
@@ -0,0 +1,89 @@
1
+ import buildDebug from "debug";
2
+ import { URL } from "node:url";
3
+ import validator from "validator";
4
+ import { HEADERS } from "@verdaccio/core";
5
+ //#region src/index.ts
6
+ var debug = buildDebug("verdaccio:core:url");
7
+ var validProtocols = ["https", "http"];
8
+ /**
9
+ * Check if URI is starting with "http://", "https://" or "//"
10
+ * @param {string} uri
11
+ */
12
+ function isURLhasValidProtocol(uri) {
13
+ return /^(https?:)?\/\//.test(uri);
14
+ }
15
+ function isHost(url = "", options = {}) {
16
+ return validator.isURL(url, {
17
+ require_host: true,
18
+ allow_trailing_dot: false,
19
+ require_valid_protocol: false,
20
+ require_port: false,
21
+ require_tld: false,
22
+ ...options
23
+ });
24
+ }
25
+ /**
26
+ * Detect running protocol (http or https)
27
+ */
28
+ function getWebProtocol(headerProtocol, protocol) {
29
+ let returnProtocol;
30
+ const [, defaultProtocol] = validProtocols;
31
+ if (typeof headerProtocol === "string" && headerProtocol !== "") {
32
+ debug("header protocol: %o", protocol);
33
+ const commaIndex = headerProtocol.indexOf(",");
34
+ returnProtocol = commaIndex > 0 ? headerProtocol.slice(0, commaIndex) : headerProtocol;
35
+ } else {
36
+ debug("req protocol: %o", headerProtocol);
37
+ returnProtocol = protocol;
38
+ }
39
+ return validProtocols.includes(returnProtocol) ? returnProtocol : defaultProtocol;
40
+ }
41
+ function wrapPrefix(prefix) {
42
+ if (prefix === "" || typeof prefix === "undefined" || prefix === null) return "";
43
+ else if (!prefix.startsWith("/") && prefix.endsWith("/")) return `/${prefix}`;
44
+ else if (!prefix.startsWith("/") && !prefix.endsWith("/")) return `/${prefix}/`;
45
+ else if (prefix.startsWith("/") && !prefix.endsWith("/")) return `${prefix}/`;
46
+ else return prefix;
47
+ }
48
+ /**
49
+ * Create base url for registry.
50
+ * @return {String} base registry url
51
+ */
52
+ function combineBaseUrl(protocol, host, prefix = "") {
53
+ debug("combined protocol %o", protocol);
54
+ debug("combined host %o", host);
55
+ debug("combined prefix %o", wrapPrefix(prefix));
56
+ const result = new URL(wrapPrefix(prefix), `${protocol}://${host}`).href;
57
+ debug("combined url %o", result);
58
+ return result;
59
+ }
60
+ function validateURL(publicUrl) {
61
+ try {
62
+ const parsed = new URL(publicUrl);
63
+ if (!validProtocols.includes(parsed.protocol.replace(":", ""))) throw Error("invalid protocol");
64
+ return true;
65
+ } catch {
66
+ return false;
67
+ }
68
+ }
69
+ function getPublicUrl(url_prefix = "", requestOptions) {
70
+ if (validateURL(process.env.VERDACCIO_PUBLIC_URL)) {
71
+ const envURL = new URL(wrapPrefix(url_prefix), process.env.VERDACCIO_PUBLIC_URL).href;
72
+ debug("public url by env %o", envURL);
73
+ return envURL;
74
+ } else if (requestOptions.headers["host"]) {
75
+ const host = requestOptions.headers["host"];
76
+ if (!isHost(host)) throw new Error("invalid host");
77
+ const protoHeader = process.env.VERDACCIO_FORWARDED_PROTO?.toLocaleLowerCase() ?? HEADERS.FORWARDED_PROTO.toLowerCase();
78
+ const forwardedProtocolHeaderValue = requestOptions.headers[protoHeader];
79
+ if (Array.isArray(forwardedProtocolHeaderValue)) throw new Error("invalid forwarded protocol header value. Reading header " + protoHeader);
80
+ const combinedUrl = combineBaseUrl(getWebProtocol(forwardedProtocolHeaderValue, requestOptions.protocol), host, url_prefix);
81
+ debug("public url by request %o", combinedUrl);
82
+ return combinedUrl;
83
+ } else return "/";
84
+ }
85
+ var isURL = validator.isURL;
86
+ //#endregion
87
+ export { combineBaseUrl, getPublicUrl, getWebProtocol, isHost, isURL, isURLhasValidProtocol, validateURL, wrapPrefix };
88
+
89
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { IncomingHttpHeaders } from 'node:http';\nimport { URL } from 'node:url';\nimport validator from 'validator';\n\nimport { HEADERS } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:core:url');\n\nconst validProtocols = ['https', 'http'];\n\n/**\n * Check if URI is starting with \"http://\", \"https://\" or \"//\"\n * @param {string} uri\n */\nexport function isURLhasValidProtocol(uri: string): boolean {\n return /^(https?:)?\\/\\//.test(uri);\n}\n\nexport function isHost(url: string = '', options = {}): boolean {\n return validator.isURL(url, {\n require_host: true,\n allow_trailing_dot: false,\n require_valid_protocol: false,\n // @ts-ignore\n require_port: false,\n require_tld: false,\n ...options,\n });\n}\n\n/**\n * Detect running protocol (http or https)\n */\nexport function getWebProtocol(headerProtocol: string | undefined, protocol: string): string {\n let returnProtocol;\n const [, defaultProtocol] = validProtocols;\n // HAProxy variant might return http,http with X-Forwarded-Proto\n if (typeof headerProtocol === 'string' && headerProtocol !== '') {\n debug('header protocol: %o', protocol);\n const commaIndex = headerProtocol.indexOf(',');\n returnProtocol = commaIndex > 0 ? headerProtocol.slice(0, commaIndex) : headerProtocol;\n } else {\n debug('req protocol: %o', headerProtocol);\n returnProtocol = protocol;\n }\n\n return validProtocols.includes(returnProtocol) ? returnProtocol : defaultProtocol;\n}\n\nexport function wrapPrefix(prefix: string | void): string {\n if (prefix === '' || typeof prefix === 'undefined' || prefix === null) {\n return '';\n } else if (!prefix.startsWith('/') && prefix.endsWith('/')) {\n return `/${prefix}`;\n } else if (!prefix.startsWith('/') && !prefix.endsWith('/')) {\n return `/${prefix}/`;\n } else if (prefix.startsWith('/') && !prefix.endsWith('/')) {\n return `${prefix}/`;\n } else {\n return prefix;\n }\n}\n\n/**\n * Create base url for registry.\n * @return {String} base registry url\n */\nexport function combineBaseUrl(protocol: string, host: string, prefix: string = ''): string {\n debug('combined protocol %o', protocol);\n debug('combined host %o', host);\n const newPrefix = wrapPrefix(prefix);\n debug('combined prefix %o', newPrefix);\n const groupedURI = new URL(wrapPrefix(prefix), `${protocol}://${host}`);\n const result = groupedURI.href;\n debug('combined url %o', result);\n return result;\n}\n\nexport function validateURL(publicUrl: string | void) {\n try {\n const parsed = new URL(publicUrl as string);\n if (!validProtocols.includes(parsed.protocol.replace(':', ''))) {\n throw Error('invalid protocol');\n }\n return true;\n } catch {\n // TODO: add error logger here\n return false;\n }\n}\n\nexport type RequestOptions = {\n /**\n * Request host (without port in Express 4).\n */\n host: string;\n /**\n * Request protocol, usually http or https.\n */\n protocol: string;\n /**\n * Request headers.\n */\n headers: IncomingHttpHeaders;\n /**\n * Request remote address. This is the IPv4 or IPv6 address of the client.\n */\n remoteAddress?: string;\n /**\n * Logged username the request, usually after token verification.\n */\n username?: string;\n};\n\nexport function getPublicUrl(url_prefix: string = '', requestOptions: RequestOptions): string {\n if (validateURL(process.env.VERDACCIO_PUBLIC_URL as string)) {\n const envURL = new URL(wrapPrefix(url_prefix), process.env.VERDACCIO_PUBLIC_URL as string).href;\n debug('public url by env %o', envURL);\n return envURL;\n } else if (requestOptions.headers['host']) {\n const host = requestOptions.headers['host'];\n if (!isHost(host)) {\n throw new Error('invalid host');\n }\n\n // 'X-Forwarded-Proto' is the default header\n const protoHeader: string =\n process.env.VERDACCIO_FORWARDED_PROTO?.toLocaleLowerCase() ??\n HEADERS.FORWARDED_PROTO.toLowerCase();\n const forwardedProtocolHeaderValue = requestOptions.headers[protoHeader];\n\n if (Array.isArray(forwardedProtocolHeaderValue)) {\n // This really should never happen - only set-cookie is allowed to have\n // multiple values.\n throw new Error('invalid forwarded protocol header value. Reading header ' + protoHeader);\n }\n\n const protocol = getWebProtocol(forwardedProtocolHeaderValue, requestOptions.protocol);\n const combinedUrl = combineBaseUrl(protocol, host, url_prefix);\n debug('public url by request %o', combinedUrl);\n return combinedUrl;\n } else {\n return '/';\n }\n}\n\nexport const isURL = validator.isURL;\n"],"mappings":";;;;;AAOA,IAAM,QAAQ,WAAW,oBAAoB;AAE7C,IAAM,iBAAiB,CAAC,SAAS,MAAM;;;;;AAMvC,SAAgB,sBAAsB,KAAsB;CAC1D,OAAO,kBAAkB,KAAK,GAAG;AACnC;AAEA,SAAgB,OAAO,MAAc,IAAI,UAAU,CAAC,GAAY;CAC9D,OAAO,UAAU,MAAM,KAAK;EAC1B,cAAc;EACd,oBAAoB;EACpB,wBAAwB;EAExB,cAAc;EACd,aAAa;EACb,GAAG;CACL,CAAC;AACH;;;;AAKA,SAAgB,eAAe,gBAAoC,UAA0B;CAC3F,IAAI;CACJ,MAAM,GAAG,mBAAmB;CAE5B,IAAI,OAAO,mBAAmB,YAAY,mBAAmB,IAAI;EAC/D,MAAM,uBAAuB,QAAQ;EACrC,MAAM,aAAa,eAAe,QAAQ,GAAG;EAC7C,iBAAiB,aAAa,IAAI,eAAe,MAAM,GAAG,UAAU,IAAI;CAC1E,OAAO;EACL,MAAM,oBAAoB,cAAc;EACxC,iBAAiB;CACnB;CAEA,OAAO,eAAe,SAAS,cAAc,IAAI,iBAAiB;AACpE;AAEA,SAAgB,WAAW,QAA+B;CACxD,IAAI,WAAW,MAAM,OAAO,WAAW,eAAe,WAAW,MAC/D,OAAO;MACF,IAAI,CAAC,OA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AM,6DAA6D,WAAW;EAI1F,MAAM,cAAc,eADH,eAAe,8BAA8B,eAAe,QAC1C,GAAU,MAAM,UAAU;EAC7D,MAAM,4BAA4B,WAAW;EAC7C,OAAO;CACT,OACE,OAAO;AAEX;AAEA,IAAa,QAAQ,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/url",
3
- "version": "13.0.5",
3
+ "version": "13.1.0",
4
4
  "description": "Verdaccio URL Utilities",
5
5
  "keywords": [
6
6
  "enterprise",
@@ -29,29 +29,42 @@
29
29
  "url": "https://opencollective.com/verdaccio"
30
30
  },
31
31
  "main": "./build/index.js",
32
+ "module": "./build/index.mjs",
32
33
  "types": "./build/index.d.ts",
34
+ "exports": {
35
+ ".": {
36
+ "import": {
37
+ "types": "./build/index.d.ts",
38
+ "default": "./build/index.mjs"
39
+ },
40
+ "require": {
41
+ "types": "./build/index.d.ts",
42
+ "default": "./build/index.js"
43
+ }
44
+ },
45
+ "./build/*": "./build/*"
46
+ },
33
47
  "publishConfig": {
34
48
  "access": "public"
35
49
  },
36
50
  "dependencies": {
37
- "@verdaccio/core": "8.1.4",
51
+ "@verdaccio/core": "8.2.0",
38
52
  "debug": "4.4.3",
39
53
  "validator": "13.15.26"
40
54
  },
41
55
  "devDependencies": {
42
56
  "node-mocks-http": "1.14.1",
57
+ "vite": "8.0.16",
43
58
  "vitest": "4.1.2"
44
59
  },
45
60
  "engines": {
46
- "node": ">=18"
61
+ "node": ">=22"
47
62
  },
48
63
  "scripts": {
49
64
  "clean": "rimraf ./build",
50
65
  "test": "vitest run",
51
66
  "type-check": "tsc --noEmit -p tsconfig.build.json",
52
- "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
53
- "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
54
- "watch": "pnpm build:js -- --watch",
55
- "build": "pnpm run build:js && pnpm run build:types"
67
+ "watch": "vite build --watch",
68
+ "build": "vite build && tsc --emitDeclarationOnly -p tsconfig.build.json"
56
69
  }
57
70
  }