diff --git a/.changeset/pretty-clouds-help.md b/.changeset/pretty-clouds-help.md new file mode 100644 index 000000000..192602866 --- /dev/null +++ b/.changeset/pretty-clouds-help.md @@ -0,0 +1,9 @@ +--- +'@verdaccio/config': minor +'@verdaccio/core': minor +'@verdaccio/types': minor +'@verdaccio/server': minor +'@verdaccio/store': minor +--- + +feat: trustProxy property diff --git a/packages/config/src/conf/default.yaml b/packages/config/src/conf/default.yaml index 75bfb6ec9..3a9876d31 100644 --- a/packages/config/src/conf/default.yaml +++ b/packages/config/src/conf/default.yaml @@ -106,6 +106,9 @@ server: # A regex for the password validation /.{3}$/ (3 characters min) # An example to limit to 10 characters minimum # passwordValidationRegex: /.{10}$/ + # Allow `req.ip` to resolve properly when Verdaccio is behind a proxy or load-balancer + # See: https://expressjs.com/en/guide/behind-proxies.html + # trustProxy: '127.0.0.1' # https://verdaccio.org/docs/configuration#offline-publish # publish: diff --git a/packages/config/src/conf/docker.yaml b/packages/config/src/conf/docker.yaml index 7a5a47b95..d794c7a9d 100644 --- a/packages/config/src/conf/docker.yaml +++ b/packages/config/src/conf/docker.yaml @@ -112,6 +112,9 @@ server: # A regex for the password validation /.{3}$/ (3 characters min) # An example to limit to 10 characters minimum # passwordValidationRegex: /.{10}$/ + # Allow `req.ip` to resolve properly when Verdaccio is behind a proxy or load-balancer + # See: https://expressjs.com/en/guide/behind-proxies.html + # trustProxy: '127.0.0.1' # https://verdaccio.org/docs/configuration#offline-publish # publish: diff --git a/packages/core/core/src/plugin-utils.ts b/packages/core/core/src/plugin-utils.ts index 01fde4b04..9b7874026 100644 --- a/packages/core/core/src/plugin-utils.ts +++ b/packages/core/core/src/plugin-utils.ts @@ -170,5 +170,5 @@ export interface IBasicAuth { } export interface ManifestFilter extends Plugin { - filterMetadata(packageInfo: Manifest): Promise; + filter_metadata(packageInfo: Manifest): Promise; } diff --git a/packages/core/types/package.json b/packages/core/types/package.json index f4294fc09..6d481a83b 100644 --- a/packages/core/types/package.json +++ b/packages/core/types/package.json @@ -30,14 +30,14 @@ "publishConfig": { "access": "public" }, - "main": "build/types.d.ts", - "types": "build/types.d.ts", + "main": "src/types.ts", + "types": "src/types.ts", "scripts": { "clean": "rimraf ./build", "test": "pnpm type-check", "build:docs": "typedoc --options ./typedoc.json --tsconfig tsconfig.build.json", "type-check": "tsc --noEmit -p tsconfig.build.json", - "build": "tsc --emitDeclarationOnly -p tsconfig.build.json" + "build": "echo 0" }, "devDependencies": { "@types/node": "16.18.10", diff --git a/packages/core/types/src/configuration.ts b/packages/core/types/src/configuration.ts index fd24c0190..e613b9b32 100644 --- a/packages/core/types/src/configuration.ts +++ b/packages/core/types/src/configuration.ts @@ -226,6 +226,8 @@ export type ServerSettingsConf = { */ pluginPrefix?: string; passwordValidationRegex?: RegExp; + // docs on `trustProxy` can be found at: https://expressjs.com/en/guide/behind-proxies.html + trustProxy?: string; }; /** diff --git a/packages/core/types/src/manifest.ts b/packages/core/types/src/manifest.ts index 7c6659cb0..14be3bd67 100644 --- a/packages/core/types/src/manifest.ts +++ b/packages/core/types/src/manifest.ts @@ -89,6 +89,12 @@ export interface Tags { [key: string]: Version; } +export interface PeerDependenciesMeta { + [dependencyName: string]: { + optional?: boolean; + }; +} + export interface Version { name: string; version: string; @@ -116,6 +122,7 @@ export interface Version { peerDependencies?: Dependencies; devDependencies?: Dependencies; optionalDependencies?: Dependencies; + peerDependenciesMeta?: PeerDependenciesMeta; bundleDependencies?: Dependencies; keywords?: string | string[]; nodeVersion?: string; @@ -127,6 +134,8 @@ export interface Version { funding?: { type: string; url: string }; engines?: Engines; hasInstallScript?: boolean; + cpu?: string[]; + os?: string[]; } export interface Dependencies { diff --git a/packages/server/express/src/server.ts b/packages/server/express/src/server.ts index a04723249..754f41578 100644 --- a/packages/server/express/src/server.ts +++ b/packages/server/express/src/server.ts @@ -31,6 +31,9 @@ const defineAPI = async function (config: IConfig, storage: Storage): Promise { - return typeof plugin.filterMetadata !== 'undefined'; + (plugin: pluginUtils.ManifestFilter) => { + return typeof plugin.filter_metadata !== 'undefined'; }, this.config?.serverSettings?.pluginPrefix ); @@ -1786,7 +1786,7 @@ class Storage { // and return it directly for // performance (i.e. need not be pure) try { - filteredManifest = await filter.filterMetadata(manifest); + filteredManifest = await filter.filter_metadata(manifest); } catch (err: any) { this.logger.error({ err: err.message }, 'filter has failed @{err}'); filterPluginErrors.push(err);