From ee442a0e39639cda4f2acd444ad6885de6e52d1b Mon Sep 17 00:00:00 2001 From: Abraham Schilling Date: Sat, 26 Oct 2019 12:45:36 +0200 Subject: [PATCH] feat: improve auth callback TS types (#225) * 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 --- core/types/index.d.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/core/types/index.d.ts b/core/types/index.d.ts index 675dbc28..d826c091 100644 --- a/core/types/index.d.ts +++ b/core/types/index.d.ts @@ -456,15 +456,17 @@ declare module '@verdaccio/types' { version?: string; } + type AuthCallback = (error: string | null, groups: string[] | false) => void; + interface IPluginAuth extends IPlugin { - 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; }