0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-13 22:48:31 -05:00
verdaccio/website/translated_docs/it/dev-plugins.md
verdacciobot 26c9f496ee New Crowdin translations (#1012)
* New translations use-cases.md (Italian)
docs(website): new translations

* New translations use-cases.md (Italian)
docs(website): new translations

* New translations use-cases.md (Italian)
docs(website): new translations

* New translations use-cases.md (Italian)
docs(website): new translations

* New translations use-cases.md (Italian)
docs(website): new translations

* New translations uplinks.md (Italian)
docs(website): new translations

* New translations use-cases.md (Italian)
docs(website): new translations

* New translations uplinks.md (Italian)
docs(website): new translations

* New translations uplinks.md (Italian)
docs(website): new translations

* New translations uplinks.md (Italian)
docs(website): new translations

* New translations uplinks.md (Italian)
docs(website): new translations

* New translations uplinks.md (Italian)
docs(website): new translations

* New translations uplinks.md (Italian)
docs(website): new translations

* New translations web.md (Italian)
docs(website): new translations

* New translations what-is-verdaccio.md (Italian)
docs(website): new translations

* New translations use-cases.md (Italian)
docs(website): new translations

* New translations test.md (Italian)
docs(website): new translations

* New translations test.md (Italian)
docs(website): new translations

* New translations test.md (Italian)
docs(website): new translations

* New translations test.md (Italian)
docs(website): new translations

* New translations test.md (Italian)
docs(website): new translations

* New translations test.md (Italian)
docs(website): new translations

* New translations test.md (Italian)
docs(website): new translations

* New translations test.md (Italian)
docs(website): new translations

* New translations test.md (Italian)
docs(website): new translations

* New translations test.md (Italian)
docs(website): new translations

* New translations ssl.md (Italian)
docs(website): new translations

* New translations test.md (Italian)
docs(website): new translations

* New translations ssl.md (Italian)
docs(website): new translations

* New translations ssl.md (Italian)
docs(website): new translations

* New translations server.md (Italian)
docs(website): new translations

* New translations ssl.md (Italian)
docs(website): new translations

* New translations server.md (Italian)
docs(website): new translations

* New translations server.md (Italian)
docs(website): new translations

* New translations server.md (Italian)
docs(website): new translations

* New translations auth.md (Italian)
docs(website): new translations

* New translations cli.md (Italian)
docs(website): new translations

* New translations ci.md (Italian)
docs(website): new translations

* New translations config.md (Italian)
docs(website): new translations

* New translations config.md (Chinese Simplified)
docs(website): new translations

* New translations web.md (Chinese Simplified)
docs(website): new translations

* New translations contributing.md (Italian)
docs(website): new translations

* New translations config.md (Chinese Simplified)
docs(website): new translations

* New translations contributing.md (Chinese Simplified)
docs(website): new translations

* New translations web.md (Chinese Simplified)
docs(website): new translations

* New translations contributing.md (Italian)
docs(website): new translations

* New translations uplinks.md (Italian)
docs(website): new translations

* New translations contributing.md (Chinese Simplified)
docs(website): new translations

* New translations contributing.md (Chinese Simplified)
docs(website): new translations

* New translations install.md (Chinese Simplified)
docs(website): new translations

* New translations windows.md (Italian)
docs(website): new translations

* New translations install.md (Chinese Simplified)
docs(website): new translations

* New translations server.md (Italian)
docs(website): new translations

* New translations server.md (Italian)
docs(website): new translations

* New translations server.md (Italian)
docs(website): new translations

* New translations server.md (Italian)
docs(website): new translations

* New translations server.md (Italian)
docs(website): new translations

* New translations server.md (Italian)
docs(website): new translations

* New translations server.md (Italian)
docs(website): new translations

* New translations uplinks.md (Italian)
docs(website): new translations

* New translations reverse-proxy.md (Italian)
docs(website): new translations

* New translations reverse-proxy.md (Italian)
docs(website): new translations

* New translations reverse-proxy.md (Italian)
docs(website): new translations

* New translations reverse-proxy.md (Italian)
docs(website): new translations

* New translations repositories.md (Italian)
docs(website): new translations

* New translations reverse-proxy.md (Italian)
docs(website): new translations

* New translations puppet.md (Italian)
docs(website): new translations

* New translations puppet.md (Italian)
docs(website): new translations

* New translations puppet.md (Italian)
docs(website): new translations

* New translations puppet.md (Italian)
docs(website): new translations

* New translations puppet.md (Italian)
docs(website): new translations

* New translations protect-your-dependencies.md (Italian)
docs(website): new translations

* New translations puppet.md (Italian)
docs(website): new translations

* New translations protect-your-dependencies.md (Italian)
docs(website): new translations

* New translations protect-your-dependencies.md (Italian)
docs(website): new translations

* New translations protect-your-dependencies.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations protect-your-dependencies.md (Italian)
docs(website): new translations

* New translations logo.md (Chinese Simplified)
docs(website): new translations

* New translations en.json (Chinese Simplified)
docs(website): new translations

* New translations logo.md (Chinese Simplified)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations server.md (Italian)
docs(website): new translations

* New translations reverse-proxy.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations uplinks.md (Italian)
docs(website): new translations

* New translations ssl.md (Italian)
docs(website): new translations

* New translations ssl.md (Italian)
docs(website): new translations

* New translations repositories.md (Italian)
docs(website): new translations

* New translations server.md (Italian)
docs(website): new translations

* New translations puppet.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations protect-your-dependencies.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations test.md (Italian)
docs(website): new translations

* New translations en.json (Arabic)
docs(website): new translations

* New translations ci.md (Italian)
docs(website): new translations

* New translations reverse-proxy.md (Italian)
docs(website): new translations

* New translations protect-your-dependencies.md (Italian)
docs(website): new translations

* New translations reverse-proxy.md (Korean)
docs(website): new translations

* New translations protect-your-dependencies.md (Korean)
docs(website): new translations

* New translations reverse-proxy.md (Polish)
docs(website): new translations

* New translations protect-your-dependencies.md (Polish)
docs(website): new translations

* New translations reverse-proxy.md (Vietnamese)
docs(website): new translations

* New translations protect-your-dependencies.md (Vietnamese)
docs(website): new translations

* New translations reverse-proxy.md (Hindi)
docs(website): new translations

* New translations protect-your-dependencies.md (Hindi)
docs(website): new translations

* New translations reverse-proxy.md (Portuguese)
docs(website): new translations

* New translations protect-your-dependencies.md (Portuguese)
docs(website): new translations

* New translations reverse-proxy.md (Russian)
docs(website): new translations

* New translations protect-your-dependencies.md (Russian)
docs(website): new translations

* New translations reverse-proxy.md (Spanish)
docs(website): new translations

* New translations protect-your-dependencies.md (Spanish)
docs(website): new translations

* New translations reverse-proxy.md (Arabic)
docs(website): new translations

* New translations protect-your-dependencies.md (Arabic)
docs(website): new translations

* New translations reverse-proxy.md (Chinese Simplified)
docs(website): new translations

* New translations protect-your-dependencies.md (Chinese Simplified)
docs(website): new translations

* New translations reverse-proxy.md (Portuguese, Brazilian)
docs(website): new translations

* New translations protect-your-dependencies.md (Portuguese, Brazilian)
docs(website): new translations

* New translations protect-your-dependencies.md (Japanese)
docs(website): new translations

* New translations reverse-proxy.md (Japanese)
docs(website): new translations

* New translations reverse-proxy.md (French)
docs(website): new translations

* New translations protect-your-dependencies.md (French)
docs(website): new translations

* New translations protect-your-dependencies.md (German)
docs(website): new translations

* New translations reverse-proxy.md (German)
docs(website): new translations

* New translations reverse-proxy.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations reverse-proxy.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations notifications.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations notifications.md (Italian)
docs(website): new translations

* New translations notifications.md (Italian)
docs(website): new translations

* New translations notifications.md (Italian)
docs(website): new translations

* New translations notifications.md (Italian)
docs(website): new translations

* New translations notifications.md (Italian)
docs(website): new translations

* New translations notifications.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations notifications.md (Italian)
docs(website): new translations

* New translations node-api.md (Italian)
docs(website): new translations

* New translations node-api.md (Italian)
docs(website): new translations

* New translations logo.md (Italian)
docs(website): new translations

* New translations logo.md (Italian)
docs(website): new translations

* New translations logo.md (Italian)
docs(website): new translations

* New translations logo.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations logger.md (Italian)
docs(website): new translations

* New translations logger.md (Italian)
docs(website): new translations

* New translations logger.md (Italian)
docs(website): new translations

* New translations kubernetes.md (Italian)
docs(website): new translations

* New translations kubernetes.md (Italian)
docs(website): new translations

* New translations kubernetes.md (Italian)
docs(website): new translations

* New translations kubernetes.md (Italian)
docs(website): new translations

* New translations kubernetes.md (Italian)
docs(website): new translations

* New translations install.md (Italian)
docs(website): new translations

* New translations kubernetes.md (Italian)
docs(website): new translations

* New translations install.md (Italian)
docs(website): new translations

* New translations notifications.md (Italian)
docs(website): new translations

* New translations packages.md (Italian)
docs(website): new translations

* New translations plugins.md (Italian)
docs(website): new translations

* New translations repositories.md (Italian)
docs(website): new translations

* New translations logger.md (Italian)
docs(website): new translations

* New translations notifications.md (Italian)
docs(website): new translations

* New translations logo.md (Italian)
docs(website): new translations

* New translations install.md (Italian)
docs(website): new translations

* New translations install.md (Italian)
docs(website): new translations

* New translations install.md (Italian)
docs(website): new translations

* New translations iis-server.md (Italian)
docs(website): new translations

* New translations iis-server.md (Italian)
docs(website): new translations

* New translations iis-server.md (Italian)
docs(website): new translations

* New translations iis-server.md (Italian)
docs(website): new translations

* New translations iis-server.md (Italian)
docs(website): new translations

* New translations iis-server.md (Italian)
docs(website): new translations

* New translations iis-server.md (Italian)
docs(website): new translations

* New translations iis-server.md (Italian)
docs(website): new translations

* New translations iis-server.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations iis-server.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations dev-plugins.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations iis-server.md (Italian)
docs(website): new translations

* New translations install.md (Italian)
docs(website): new translations

* New translations iis-server.md (Italian)
docs(website): new translations

* New translations docker.md (Italian)
docs(website): new translations

* New translations iis-server.md (Italian)
docs(website): new translations
2018-09-26 10:09:19 +02:00

6.5 KiB

id title
dev-plugins Sviluppare Estensioni

Esistono diversi modi di ampliare verdaccio, i tipi di estensioni supportati sono:

  • Plugin di autenticazione
  • Plugin Middleware (da v2.7.0)
  • Plugin di archiviazione da (v3.x)

Consigliamo di sviluppare estensioni utilizzando le nostre definizioni di tipo di flusso.

Plugin di autenticazione

Fondamentalmente dobbiamo restituire un oggetto con un unico metodo chiamato authenticate che riceverà 3 argomenti (user, password, callback).

API

interface IPluginAuth extends IPlugin {
  login_url?: string;
  authenticate(user: string, password: string, cb: Callback): void;
  adduser(user: string, password: string, cb: Callback): void;
  allow_access(user: RemoteUser, pkg: $Subtype<PackageAccess>, cb: Callback): void;
  allow_publish(user: RemoteUser, pkg: $Subtype<PackageAccess>, cb: Callback): void;
}

Solamente adduser, allow_access e allow_publish sono facoltativi, verdaccio fornisce una soluzione di ripiego in tutti questi casi.

Callback

Una volta che l'autenticazione viene eseguita, esistono 2 possibili opzioni per dare una risposta a verdaccio.

OnError

Nel caso in cui qualcosa sia andato storto oppure l'auth sia fallita.

callback(null, false)
OnSuccess

Nel caso in cui l'auth sia andata a buon fine.

groups è un array di stringhe di cui l'utente fa parte.

 callback(null, groups);

Esempio

function Auth(config, stuff) {
  var self = Object.create(Auth.prototype);
  self._users = {};

  // config for this module
  self._config = config;

  // verdaccio logger
  self._logger = stuff.logger;

  // pass verdaccio logger to ldapauth
  self._config.client_options.log = stuff.logger;

  return self;
}

Auth.prototype.authenticate = function (user, password, callback) {
  var LdapClient = new LdapAuth(self._config.client_options);
  ....
  LdapClient.authenticate(user, password, function (err, ldapUser) {
    ...
    var groups;
     ...
    callback(null, groups);
  });
};

module.exports = Auth;

E la configurazione apparirà così:

auth:
  htpasswd:
    file: ./htpasswd

Dove htpasswd è il suffisso del nome del plugin. es: verdaccio-htpasswd ed il resto del body sarebbe composto dai parametri di configurazione del plugin.

Plugin Middleware

Le estensioni Middleware possiedono la capacità di modificare il livello API, aggiungendo nuovi endpoint o intercettando richieste.

interface verdaccio$IPluginMiddleware extends verdaccio$IPlugin {
  register_middlewares(app: any, auth: IBasicAuth, storage: IStorageManager): void;
}

register_middlewares

Questo metodo fornisce un accesso completo all'autenticazione ed all'archiviazione tramite auth and storage. app è l'applicazione rapida che permette l'aggiunta di nuovi endpoint.

Un bell'esempio di plugin middleware è il sinopia-github-oauth ed il verdaccio-audit.

API

function register_middlewares(expressApp, authInstance, storageInstance) {
   /* more stuff */
}

Per registrare un middleware necessitiamo di un oggetto con un unico metodo chiamato register_middlewares il quale riceverà 3 argomenti (expressApp, auth, storage). Auth è l'istanza di autenticazione e storage è anche la principale istanza di Archiviazione che darà accesso a tutte le azioni di memorizzazione.

Plugin di archiviazione

Verdaccio di default utilizza un'estensione di archiviazione del file system local-storage, ma, dalla versione di verdaccio@3.x in poi è possibile collegarne una personalizzata che sostituisca la condotta predefinita.

API

L'API di archiviazione è un po' più complessa, è necessario creare una classe che restituisca un'implementazione IPluginStorage. Si prega di leggere i dettagli qui sotto.

class LocalDatabase<IPluginStorage>{
  constructor(config: $Subtype<verdaccio$Config>, logger: verdaccio$Logger): ILocalData;
}

interface IPluginStorage {
  logger: verdaccio$Logger;
    config: $Subtype<verdaccio$Config>;
  add(name: string, callback: verdaccio$Callback): void;
  remove(name: string, callback: verdaccio$Callback): void;
  get(callback: verdaccio$Callback): void;
  getSecret(): Promise<string>;
  setSecret(secret: string): Promise<any>;
  getPackageStorage(packageInfo: string): verdaccio$IPackageStorage;
  search(onPackage: verdaccio$Callback, onEnd: verdaccio$Callback, validateName: Function): void;
}

interface IPackageStorageManager {
  path: string;
  logger: verdaccio$Logger;
  writeTarball(name: string): verdaccio$IUploadTarball;
  readTarball(name: string): verdaccio$IReadTarball;
  readPackage(fileName: string, callback: verdaccio$Callback): void;
  createPackage(name: string, value: verdaccio$Package, cb: verdaccio$Callback): void;
  deletePackage(fileName: string, callback: verdaccio$Callback): void;
  removePackage(callback: verdaccio$Callback): void;
  updatePackage(pkgFileName: string,
                updateHandler: verdaccio$Callback,
                onWrite: verdaccio$Callback,
                transformPackage: Function,
                onEnd: verdaccio$Callback): void;
  savePackage(fileName: string, json: verdaccio$Package, callback: verdaccio$Callback): void;
}

class verdaccio$IUploadTarball extends stream$PassThrough {
  abort: Function;
  done: Function;
  _transform: Function;
  abort(): void;
  done(): void;
}

class verdaccio$IReadTarball extends stream$PassThrough {
  abort: Function;
  abort(): void;
}

L'API di archiviazione è ancora in via sperimentale e potrebbe cambiare nelle successive versioni minori. Per ulteriori informazioni sull'API di archiviazione si prega di seguire le definizioni dei tipi nel nostro archivio ufficiale.

Esempi di Plugin di Archiviazione

Il seguente è un elenco di estensioni che utilizzano l'API di archiviazione e che potrebbero essere utilizzate come esempio.

Sei disposto a contribuire con nuovi Plugin di Archiviazione? Clicca qui.