0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-03-11 02:15:57 -05:00
verdaccio/website/docs/plugin-filter.md
2025-03-02 10:54:40 +01:00

1.3 KiB

id title
plugin-filter Filter Plugin

What's a filter plugin?

:::caution

Filter plugins are experimental and requires more users feedback

:::

When to use a filter plugin?

If you need to mutate the metadata for different reasons this is a way to do it, all manifest request are intercepted, but the tarballs, user, profile or tokens requests are not included. A good example to review is the verdaccio-plugin-secfilter.

Plugin structure

The plugin only has one async method named filter_metadata that reference of the manifest and must return a copy (or modified object but not recommended) of the metadata.

export default class VerdaccioMiddlewarePlugin implements IPluginStorageFilter<CustomConfig> {
  async filter_metadata(metadata: Readonly<Manifest>): Promise<Package> {
    // modify the metadata
    const newMetadata = { ...metadata, ...{ name: 'fooName' } };
    return newMetadata;
  }
}

Configuration

Just add filters to the config.yaml file and your own plugin options.

filters:
  storage-filter-blackwhitelist:
    filter_file: /path/to/file

More info in the PR.