UNPKG

bauth-js

Version:

A Node.js authentication library for API requests via remote authentication service using Bearer tokens. Compatible with Express and NestJS.

38 lines 1.35 kB
import { BAuthConfig } from '../types'; interface CanActivate { canActivate(context: any): Promise<boolean>; } interface ExecutionContext { switchToHttp(): { getRequest(): any; }; } export interface BAuthNestOptions extends BAuthConfig { userProperty?: string; tokenExtractor?: (context: ExecutionContext) => string | null; } export declare class BAuthGuard implements CanActivate { private auth; private options; constructor(options: BAuthNestOptions); canActivate(context: ExecutionContext): Promise<boolean>; private extractToken; } /** * Decorator to mark routes that require authentication * Note: This is a placeholder. In a real NestJS environment, * you would use the actual NestJS decorators. */ export declare const UseBAuth: (options: BAuthNestOptions) => (_target: any, _propertyKey?: string, _descriptor?: PropertyDescriptor) => void; /** * Decorator to get the authenticated user * Note: This is a placeholder. In a real NestJS environment, * you would use the actual NestJS decorators. */ export declare const CurrentUser: () => (_target: any, _propertyKey: string, _parameterIndex: number) => void; /** * Factory function to create BAuthGuard */ export declare function createBAuthGuard(options: BAuthNestOptions): typeof BAuthGuard; export {}; //# sourceMappingURL=nest.d.ts.map