@verdaccio/url 11.0.0-6-next.14 → 11.0.0-6-next.16

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Change Log
2
2
 
3
+ ## 11.0.0-6-next.16
4
+
5
+ ### Patch Changes
6
+
7
+ - @verdaccio/core@6.0.0-6-next.50
8
+
9
+ ## 11.0.0-6-next.15
10
+
11
+ ### Minor Changes
12
+
13
+ - ce013d2f: refactor: npm star command support reimplemented
14
+
15
+ ### Patch Changes
16
+
17
+ - @verdaccio/core@6.0.0-6-next.49
18
+
3
19
  ## 11.0.0-6-next.14
4
20
 
5
21
  ### Patch Changes
package/build/index.d.ts CHANGED
@@ -16,11 +16,24 @@ export declare function wrapPrefix(prefix: string | void): string;
16
16
  export declare function combineBaseUrl(protocol: string, host: string, prefix?: string): string;
17
17
  export declare function validateURL(publicUrl: string | void): boolean;
18
18
  export declare type RequestOptions = {
19
+ /**
20
+ * Request host.
21
+ */
19
22
  host: string;
23
+ /**
24
+ * Request protocol.
25
+ */
20
26
  protocol: string;
27
+ /**
28
+ * Request headers.
29
+ */
21
30
  headers: {
22
31
  [key: string]: string;
23
32
  };
24
33
  remoteAddress?: string;
34
+ /**
35
+ * Logged username the request, usually after token verification.
36
+ */
37
+ username?: string;
25
38
  };
26
39
  export declare function getPublicUrl(url_prefix: string | undefined, requestOptions: RequestOptions): string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["debug","buildDebug","validProtocols","isURLhasValidProtocol","uri","test","isHost","url","options","isURLValidator","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","err","getPublicUrl","url_prefix","requestOptions","process","env","VERDACCIO_PUBLIC_URL","envURL","headers","protoHeader","VERDACCIO_FORWARDED_PROTO","toLocaleLowerCase","HEADERS","FORWARDED_PROTO","toLowerCase","combinedUrl"],"sources":["../src/index.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { URL } from 'url';\nimport isURLValidator from 'validator/lib/isURL';\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 isURLValidator(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 | void, 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 (err: any) {\n // TODO: add error logger here\n return false;\n }\n}\n\nexport type RequestOptions = {\n host: string;\n protocol: string;\n headers: { [key: string]: string };\n remoteAddress?: 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 const protoHeader =\n process.env.VERDACCIO_FORWARDED_PROTO?.toLocaleLowerCase() ??\n HEADERS.FORWARDED_PROTO.toLowerCase();\n const protocol = getWebProtocol(requestOptions.headers[protoHeader], 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"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;AAEA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,oBAAX,CAAd;AAEA,MAAMC,cAAc,GAAG,CAAC,OAAD,EAAU,MAAV,CAAvB;AAEA;AACA;AACA;AACA;;AACO,SAASC,qBAAT,CAA+BC,GAA/B,EAAqD;EAC1D,OAAO,kBAAkBC,IAAlB,CAAuBD,GAAvB,CAAP;AACD;;AAEM,SAASE,MAAT,CAAgBC,GAAW,GAA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jB;IACA,OAAO,KAAP;EACD;AACF;;AASM,SAASC,YAAT,CAAsBC,UAAkB,GAAG,EAA3C,EAA+CC,cAA/C,EAAuF;EAC5F,IAAIR,WAAW,CAACS,OAAO,CAACC,GAAR,CAAYC,oBAAb,CAAf,EAA6D;IAC3D,MAAMC,MAAM,GAAG,IAAIf,QAAJ,CAAQR,UAAU,CAACkB,UAAD,CAAlB,EAAgCE,OAAO,CAACC,GAAR,CAAYC,oBAA5C,EAA4EZ,IAA3F;IACAlC,KAAK,CAAC,sBAAD,EAAyB+C,MAAzB,CAAL;IACA,OAAOA,MAAP;EACD,CAJD,MAIO,IAAIJ,cAAc,CAACK,OAAf,CAAuB,MAAvB,CAAJ,EAAoC;IAAA;;IACzC,MAAMnB,IAAI,GAAGc,cAAc,CAACK,OAAf,CAAuB,MAAvB,CAAb;;IACA,IAAI,CAAC1C,MAAM,CAACuB,IAAD,CAAX,EAAmB;MACjB,MAAM,IAAIU,KAAJ,CAAU,cAAV,CAAN;IACD;;IACD,MAAMU,WAAW,GACf,0BAAAL,OAAO,CAACC,GAAR,CAAYK,yBAAZ,gFAAuCC,iBAAvC,OACAC,aAAA,CAAQC,eAAR,CAAwBC,WAAxB,EAFF;;IAGA,MAAMrC,QAAQ,GAAGF,cAAc,CAAC4B,cAAc,CAACK,OAAf,CAAuBC,WAAvB,CAAD,EAAsCN,cAAc,CAAC1B,QAArD,CAA/B;IACA,MAAMsC,WAAW,GAAG3B,cAAc,CAACX,QAAD,EAAWY,IAAX,EAAiBa,UAAjB,CAAlC;IACA1C,KAAK,CAAC,0BAAD,EAA6BuD,WAA7B,CAAL;IACA,OAAOA,WAAP;EACD,CAZM,MAYA;IACL,OAAO,GAAP;EACD;AACF"}
1
+ {"version":3,"file":"index.js","names":["debug","buildDebug","validProtocols","isURLhasValidProtocol","uri","test","isHost","url","options","isURLValidator","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","err","getPublicUrl","url_prefix","requestOptions","process","env","VERDACCIO_PUBLIC_URL","envURL","headers","protoHeader","VERDACCIO_FORWARDED_PROTO","toLocaleLowerCase","HEADERS","FORWARDED_PROTO","toLowerCase","combinedUrl"],"sources":["../src/index.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { URL } from 'url';\nimport isURLValidator from 'validator/lib/isURL';\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 isURLValidator(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 | void, 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 (err: any) {\n // TODO: add error logger here\n return false;\n }\n}\n\nexport type RequestOptions = {\n /**\n * Request host.\n */\n host: string;\n /**\n * Request protocol.\n */\n protocol: string;\n /**\n * Request headers.\n */\n headers: { [key: string]: string };\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 const protoHeader =\n process.env.VERDACCIO_FORWARDED_PROTO?.toLocaleLowerCase() ??\n HEADERS.FORWARDED_PROTO.toLowerCase();\n const protocol = getWebProtocol(requestOptions.headers[protoHeader], 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"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;AAEA,MAAMA,KAAK,GAAG,IAAAC,cAAA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,CAAL;IACA,OAAOA,WAAP;EACD,CAZM,MAYA;IACL,OAAO,GAAP;EACD;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/url",
3
- "version": "11.0.0-6-next.14",
3
+ "version": "11.0.0-6-next.16",
4
4
  "description": "url utilities resolver",
5
5
  "keywords": [
6
6
  "private",
@@ -34,7 +34,7 @@
34
34
  "access": "public"
35
35
  },
36
36
  "dependencies": {
37
- "@verdaccio/core": "6.0.0-6-next.48",
37
+ "@verdaccio/core": "6.0.0-6-next.50",
38
38
  "debug": "4.3.4",
39
39
  "lodash": "4.17.21",
40
40
  "validator": "13.7.0"
package/src/index.ts CHANGED
@@ -90,10 +90,23 @@ export function validateURL(publicUrl: string | void) {
90
90
  }
91
91
 
92
92
  export type RequestOptions = {
93
+ /**
94
+ * Request host.
95
+ */
93
96
  host: string;
97
+ /**
98
+ * Request protocol.
99
+ */
94
100
  protocol: string;
101
+ /**
102
+ * Request headers.
103
+ */
95
104
  headers: { [key: string]: string };
96
105
  remoteAddress?: string;
106
+ /**
107
+ * Logged username the request, usually after token verification.
108
+ */
109
+ username?: string;
97
110
  };
98
111
 
99
112
  export function getPublicUrl(url_prefix: string = '', requestOptions: RequestOptions): string {