Skip to content

Commit

Permalink
feat: improve auth callback TS types (#225)
Browse files Browse the repository at this point in the history
* Improve auth callback TS types

Adds a bit more validation for auth callbacks. See https://verdaccio.org/docs/en/dev-plugins#callback

* 459:79  error  Insert `;`  prettier/prettier
  • Loading branch information
n4bb12 authored and juanpicado committed Oct 26, 2019
1 parent 00b66af commit ee442a0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions core/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,15 +456,17 @@ declare module '@verdaccio/types' {
version?: string;
}

type AuthCallback = (error: string | null, groups: string[] | false) => void;

interface IPluginAuth<T> extends IPlugin<T> {
authenticate(user: string, password: string, cb: Callback): void;
adduser?(user: string, password: string, cb: Callback): void;
changePassword?(user: string, password: string, newPassword: string, cb: Callback): void;
allow_access?(user: RemoteUser, pkg: T & PackageAccess, cb: Callback): void;
allow_publish?(user: RemoteUser, pkg: T & PackageAccess, cb: Callback): void;
allow_access?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: Callback): void;
allow_publish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: Callback): void;
allow_unpublish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: Callback): void;
authenticate(user: string, password: string, cb: AuthCallback): void;
adduser?(user: string, password: string, cb: AuthCallback): void;
changePassword?(user: string, password: string, newPassword: string, cb: AuthCallback): void;
allow_access?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthCallback): void;
allow_publish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthCallback): void;
allow_access?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthCallback): void;
allow_publish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthCallback): void;
allow_unpublish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthCallback): void;
apiJWTmiddleware?(helpers: any): Function;
}

Expand Down

0 comments on commit ee442a0

Please sign in to comment.