From 97538f886271ccdbea7862957f65c4a17c4cd831 Mon Sep 17 00:00:00 2001 From: Andrey Frimuchkov Date: Sat, 18 Jul 2020 00:00:14 +0300 Subject: [PATCH] fix: incorrect AuthAccessCallback and AuthCallback (#374) https://github.com/verdaccio/verdaccio/blob/master/src/lib/auth.ts#L264 https://github.com/verdaccio/verdaccio/blob/master/src/lib/auth.ts#L114 --- core/types/index.d.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/core/types/index.d.ts b/core/types/index.d.ts index 03b56071..5e289b74 100644 --- a/core/types/index.d.ts +++ b/core/types/index.d.ts @@ -496,8 +496,21 @@ declare module '@verdaccio/types' { tag?: string; } - type AuthAccessCallback = (error: string | null, access: boolean) => void; - type AuthCallback = (error: string | null, groups: string[] | false) => void; + // FIXME: error should be export type `VerdaccioError = HttpError & { code: number };` instead of AuthError + // but this type is on @verdaccio/commons-api and cannot be used here yet (I don't know why) + interface HttpError extends Error { + status: number; + statusCode: number; + expose: boolean; + headers?: { + [key: string]: string; + }; + [key: string]: any; + } + + type AuthError = HttpError & { code: number }; + type AuthAccessCallback = (error: AuthError | null, access: boolean) => void; + type AuthCallback = (error: AuthError | null, groups: string[] | false) => void; interface IPluginAuth extends IPlugin { authenticate(user: string, password: string, cb: AuthCallback): void;