@verdaccio/url 11.0.0-6-next.8 → 11.0.0-6-next.11

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,54 @@
1
1
  # Change Log
2
2
 
3
+ ## 11.0.0-6-next.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 351aeeaa: fix(deps): @verdaccio/utils should be a prod dep of local-storage
8
+ - Updated dependencies [351aeeaa]
9
+ - @verdaccio/core@6.0.0-6-next.7
10
+
11
+ ## 11.0.0-6-next.10
12
+
13
+ ### Major Changes
14
+
15
+ - 292c0a37: feat!: replace deprecated request dependency by got
16
+
17
+ This is a big refactoring of the core, fetching dependencies, improve code, more tests and better stability. This is essential for the next release, will take some time but would allow modularize more the core.
18
+
19
+ ## Notes
20
+
21
+ - Remove deprecated `request` by other `got`, retry improved, custom Agent ( got does not include it built-in)
22
+ - Remove `async` dependency from storage (used by core) it was linked with proxy somehow safe to remove now
23
+ - Refactor with promises instead callback wherever is possible
24
+ - ~Document the API~
25
+ - Improve testing, integration tests
26
+ - Bugfix
27
+ - Clean up old validations
28
+ - Improve performance
29
+
30
+ ## 💥 Breaking changes
31
+
32
+ - Plugin API methods were callbacks based are returning promises, this will break current storage plugins, check documentation for upgrade.
33
+ - Write Tarball, Read Tarball methods parameters change, a new set of options like `AbortController` signals are being provided to the `addAbortSignal` can be internally used with Streams when a request is aborted. eg: `addAbortSignal(signal, fs.createReadStream(pathName));`
34
+ - `@verdaccio/streams` stream abort support is legacy is being deprecated removed
35
+ - Remove AWS and Google Cloud packages for future refactoring [#2574](https://github.com/verdaccio/verdaccio/pull/2574).
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies [292c0a37]
40
+ - Updated dependencies [a3a209b5]
41
+ - Updated dependencies [00d1d2a1]
42
+ - @verdaccio/core@6.0.0-6-next.6
43
+
44
+ ## 11.0.0-6-next.9
45
+
46
+ ### Patch Changes
47
+
48
+ - Updated dependencies [82cb0f2b]
49
+ - Updated dependencies [5167bb52]
50
+ - @verdaccio/core@6.0.0-6-next.5
51
+
3
52
  ## 11.0.0-6-next.8
4
53
 
5
54
  ### Patch Changes
package/build/index.d.ts CHANGED
@@ -21,5 +21,6 @@ export declare type RequestOptions = {
21
21
  headers: {
22
22
  [key: string]: string;
23
23
  };
24
+ remoteAddress?: string;
24
25
  };
25
26
  export declare function getPublicUrl(url_prefix: string | undefined, requestOptions: RequestOptions): string;
package/build/index.js CHANGED
@@ -55,7 +55,7 @@ function getWebProtocol(headerProtocol, protocol) {
55
55
  if (typeof headerProtocol === 'string' && headerProtocol !== '') {
56
56
  debug('header protocol: %o', protocol);
57
57
  const commaIndex = headerProtocol.indexOf(',');
58
- returnProtocol = commaIndex > 0 ? headerProtocol.substr(0, commaIndex) : headerProtocol;
58
+ returnProtocol = commaIndex > 0 ? headerProtocol.slice(0, commaIndex) : headerProtocol;
59
59
  } else {
60
60
  debug('req protocol: %o', headerProtocol);
61
61
  returnProtocol = protocol;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["debug","validProtocols","isURLhasValidProtocol","uri","test","isHost","url","options","require_host","allow_trailing_dot","require_valid_protocol","require_port","require_tld","getWebProtocol","headerProtocol","protocol","returnProtocol","defaultProtocol","commaIndex","indexOf","substr","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"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;AAEA,MAAMA,KAAK,GAAG,oBAAW,oBAAX,CAAd;AAEA,MAAMC,cAAc,GAAG,CAAC,OAAD,EAAU,MAAV,CAAvB;AAEA;AACA;AACA;A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,WAAOA,WAAP;AACD,GAZM,MAYA;AACL,WAAO,GAAP;AACD;AACF","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.substr(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};\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"],"file":"index.js"}
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,GAAG,EAA9B,EAAkCC,OAAO,GAAG,EAA5C,EAAyD;EAC9D,OAAO,IAAAC,cAAA,EAAeF,GAAf,E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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"}
package/package.json CHANGED
@@ -1,59 +1,60 @@
1
1
  {
2
- "name": "@verdaccio/url",
3
- "version": "11.0.0-6-next.8",
4
- "description": "url utilities resolver",
5
- "keywords": [
6
- "private",
7
- "package",
8
- "repository",
9
- "registry",
10
- "enterprise",
11
- "modules",
12
- "proxy",
13
- "server",
14
- "verdaccio"
15
- ],
16
- "main": "./build/index.js",
17
- "types": "./build/index.d.ts",
18
- "author": "Juan Picado <juanpicado19@gmail.com>",
19
- "license": "MIT",
20
- "homepage": "https://verdaccio.org",
21
- "engines": {
22
- "node": ">=14",
23
- "npm": ">=6"
24
- },
25
- "repository": {
26
- "type": "https",
27
- "url": "https://github.com/verdaccio/verdaccio",
28
- "directory": "packages/core/url-resolver"
29
- },
30
- "bugs": {
31
- "url": "https://github.com/verdaccio/verdaccio/issues"
32
- },
33
- "publishConfig": {
34
- "access": "public"
35
- },
36
- "dependencies": {
37
- "@verdaccio/core": "6.0.0-6-next.4",
38
- "debug": "4.3.3",
39
- "lodash": "4.17.21",
40
- "validator": "13.7.0"
41
- },
42
- "devDependencies": {
43
- "@verdaccio/types": "11.0.0-6-next.10",
44
- "node-mocks-http": "1.10.1"
45
- },
46
- "funding": {
47
- "type": "opencollective",
48
- "url": "https://opencollective.com/verdaccio"
49
- },
50
- "scripts": {
51
- "clean": "rimraf ./build",
52
- "test": "cross-env NODE_ENV=test BABEL_ENV=test jest",
53
- "type-check": "tsc --noEmit -p tsconfig.build.json",
54
- "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
55
- "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
56
- "watch": "pnpm build:js -- --watch",
57
- "build": "pnpm run build:js && pnpm run build:types"
58
- }
59
- }
2
+ "name": "@verdaccio/url",
3
+ "version": "11.0.0-6-next.11",
4
+ "description": "url utilities resolver",
5
+ "keywords": [
6
+ "private",
7
+ "package",
8
+ "repository",
9
+ "registry",
10
+ "enterprise",
11
+ "modules",
12
+ "proxy",
13
+ "server",
14
+ "verdaccio"
15
+ ],
16
+ "main": "./build/index.js",
17
+ "types": "./build/index.d.ts",
18
+ "author": "Juan Picado <juanpicado19@gmail.com>",
19
+ "license": "MIT",
20
+ "homepage": "https://verdaccio.org",
21
+ "engines": {
22
+ "node": ">=14",
23
+ "npm": ">=6"
24
+ },
25
+ "repository": {
26
+ "type": "https",
27
+ "url": "https://github.com/verdaccio/verdaccio",
28
+ "directory": "packages/core/url-resolver"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/verdaccio/verdaccio/issues"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "dependencies": {
37
+ "@verdaccio/core": "6.0.0-6-next.7",
38
+ "debug": "4.3.4",
39
+ "lodash": "4.17.21",
40
+ "validator": "13.7.0"
41
+ },
42
+ "devDependencies": {
43
+ "@verdaccio/types": "11.0.0-6-next.15",
44
+ "node-mocks-http": "1.11.0"
45
+ },
46
+ "funding": {
47
+ "type": "opencollective",
48
+ "url": "https://opencollective.com/verdaccio"
49
+ },
50
+ "scripts": {
51
+ "clean": "rimraf ./build",
52
+ "test": "jest",
53
+ "type-check": "tsc --noEmit -p tsconfig.build.json",
54
+ "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
55
+ "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
56
+ "watch": "pnpm build:js -- --watch",
57
+ "build": "pnpm run build:js && pnpm run build:types"
58
+ },
59
+ "readme": "# Streams\n\n[![CircleCI](https://circleci.com/gh/verdaccio/streams.svg?style=svg)](https://circleci.com/gh/ayusharma/@verdaccio/streams)\n[![codecov](https://codecov.io/gh/verdaccio/streams/branch/master/graph/badge.svg)](https://codecov.io/gh/verdaccio/streams)\n[![verdaccio (latest)](https://img.shields.io/npm/v/@verdaccio/streams/latest.svg)](https://www.npmjs.com/package/@verdaccio/streams)\n[![backers](https://opencollective.com/verdaccio/tiers/backer/badge.svg?label=Backer&color=brightgreen)](https://opencollective.com/verdaccio)\n[![discord](https://img.shields.io/discord/388674437219745793.svg)](http://chat.verdaccio.org/)\n![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)\n[![node](https://img.shields.io/node/v/@verdaccio/streams/latest.svg)](https://www.npmjs.com/package/@verdaccio/streams)\n\nThis project provides an extension of `PassThrough` stream.\n\n## Detail\n\nIt provides 2 additional methods `abort()` and `done()`. Those implementations are widely use in the verdaccio core for handle `tarballs`.\n\n## License\n\nMIT (http://www.opensource.org/licenses/mit-license.php)\n"
60
+ }
package/src/index.ts CHANGED
@@ -38,7 +38,7 @@ export function getWebProtocol(headerProtocol: string | void, protocol: string):
38
38
  if (typeof headerProtocol === 'string' && headerProtocol !== '') {
39
39
  debug('header protocol: %o', protocol);
40
40
  const commaIndex = headerProtocol.indexOf(',');
41
- returnProtocol = commaIndex > 0 ? headerProtocol.substr(0, commaIndex) : headerProtocol;
41
+ returnProtocol = commaIndex > 0 ? headerProtocol.slice(0, commaIndex) : headerProtocol;
42
42
  } else {
43
43
  debug('req protocol: %o', headerProtocol);
44
44
  returnProtocol = protocol;
@@ -93,6 +93,7 @@ export type RequestOptions = {
93
93
  host: string;
94
94
  protocol: string;
95
95
  headers: { [key: string]: string };
96
+ remoteAddress?: string;
96
97
  };
97
98
 
98
99
  export function getPublicUrl(url_prefix: string = '', requestOptions: RequestOptions): string {