1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-17 07:45:52 +01:00
verdaccio/website/translated_docs/pl/dev-plugins.md
verdacciobot 45a4b17399 docs(website): new translations
* New translations dev-plugins.md (Vietnamese)
docs(website): new translations

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

* New translations ansible.md (Polish)
docs(website): new translations

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

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

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

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

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

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

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

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

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

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

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

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

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

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

* New translations build.md (Russian)
docs(website): new translations

* New translations build.md (Russian)
docs(website): new translations

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

* New translations chef.md (Russian)
docs(website): new translations

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

* New translations install.md (Portuguese, Brazilian)
docs(website): new translations

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

* New translations en.json (Portuguese, Brazilian)
docs(website): new translations

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

* New translations logo.md (Portuguese, Brazilian)
docs(website): new translations

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

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

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

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

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

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

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

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

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

* New translations web.md (Portuguese, Brazilian)
docs(website): new translations

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

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

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

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

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

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

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

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

* New translations ansible.md (Hindi)
docs(website): new translations

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

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

* New translations chef.md (Hindi)
docs(website): new translations

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

* New translations build.md (Hindi)
docs(website): new translations

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

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

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

* New translations build.md (Polish)
docs(website): new translations

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

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

* New translations chef.md (Polish)
docs(website): new translations

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

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

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

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

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

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

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

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

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

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

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

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

* New translations iis-server.md (Polish)
docs(website): new translations
2018-08-25 12:18:46 +02:00

6.3 KiB

id title
dev-plugins Tworzenie wtyczek

Istnieje wiele sposobów na rozszerzenie funkcjonalności verdaccio, wspierane są następujące rodzaje wtyczek:

  • Wtyczki uwierzytelniania
  • Wtyczki oprogramowania pośredniego (od wersji v2.7.0)
  • Wtyczki magazynu danych od wersji (v3.x)

We recommend developing plugins using our flow type definitions.

Wtyczka uwierzytelniania

Musimy tylko zwrócić obiekt pojedynczą metodą authenticate, która otrzyma 3 argumenty (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;
}

Only adduser, allow_access and allow_publish are optional, verdaccio provide a fallback in all those cases.

Callback

Po wykonaniu uwierzytelniania mamy 2 opcje na odpowiedź do verdaccio.

OnError

Gdy coś złego się wydarzy, lub uwierzytelnianie nie powiedzie się.

callback(null, false)
OnSuccess

Uwierzytelnianie zakończone sukcesem.

groups is an array of strings where the user is part of.

 callback(null, groups);

Example

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;

Konfiguracja będzie wyglądać następująco:

auth:
  htpasswd:
    file: ./htpasswd

Where htpasswd is the sufix of the plugin name. eg: verdaccio-htpasswd and the rest of the body would be the plugin configuration params.

Wtyczka oprogramowania pośredniego

Middleware plugins have the capability to modify the API layer, either adding new endpoints or intercepting requests.

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

register_middlewares

The method provide full access to the authentification and storage via auth and storage. app is the express application that allows you to add new endpoints.

A pretty good example of middleware plugin is the sinopia-github-oauth and verdaccio-audit.

API

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

Aby zarejestrować oprogramowanie pośrednie potrzebujemy obiekt z pojedynczą metodą register_middlewares, która otrzyma 3 argumenty (expressApp, auth, storage). Auth is the authentification instance and storage is also the main Storage instance that will give you have access to all to the storage actions.

Wtyczka magazynu danych

Verdaccio by default uses a file system storage plugin local-storage, but, since verdaccio@3.x you can plug in a custom storage replacing the default behaviour.

API

API magazynu danych jest trochę bardziej skomplikowane, będziesz musiał stworzyć klasę, która zwraca implementację IPluginStorage. Poniżej zapoznasz się ze szczegółami.

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;
}

API magazynu danych jest nadal w fazie eksperymentalnej i może się zmienić w następnej pomniejszej wersji. For further information about Storage API please follow the types definitions in our official repository.

Przykłady wtyczek magazynu danych

Poniższa lista wtyczek wdraża API magazynu danych oraz mogą być użyte jako przykład.

Chciałbyś współtworzyć ten projekt z nowymi wtyczkami magazynu danych? Kliknij tutaj.