@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
65 lines (64 loc) • 2.23 kB
TypeScript
import type { AuthProviderConfig, CustomAuthConfig, AuthUser, AuthSession, TokenValidationResult, AuthRequestContext, AuthHealthCheck } from "../../types/index.js";
import { BaseAuthProvider } from "./BaseAuthProvider.js";
/**
* Custom Authentication Provider
*
* Allows users to provide their own authentication logic through callback functions.
* Useful for integrating with custom auth systems or implementing unique auth flows.
*
* Features:
* - Custom token validation via callback
* - Custom user fetching (optional)
* - Custom session creation (optional, delegates to base when not provided)
* - Session management (inherited from BaseAuthProvider)
*
* @example
* ```typescript
* const custom = new CustomAuthProvider({
* type: "custom",
* validateToken: async (token, context) => {
* // Your custom token validation logic
* const decoded = await myAuthService.verify(token);
* return {
* valid: !!decoded,
* user: decoded ? {
* id: decoded.sub,
* email: decoded.email,
* roles: decoded.roles || [],
* permissions: decoded.permissions || [],
* } : undefined,
* };
* },
* getUser: async (userId) => {
* // Your custom user fetching logic
* return myUserService.getById(userId);
* },
* });
*
* const result = await custom.authenticateToken(token);
* ```
*/
export declare class CustomAuthProvider extends BaseAuthProvider {
readonly type: "custom";
private validateTokenFn;
private getUserFn?;
private createSessionFn?;
constructor(config: AuthProviderConfig & CustomAuthConfig);
/**
* Validate token using custom function
*/
authenticateToken(token: string, context?: AuthRequestContext): Promise<TokenValidationResult>;
/**
* Create a new session.
* Uses custom function if provided, otherwise delegates to BaseAuthProvider.
*/
createSession(user: AuthUser, context?: AuthRequestContext): Promise<AuthSession>;
/**
* Get user by ID using custom function
*/
getUser(userId: string): Promise<AuthUser | null>;
/**
* Health check - always healthy for custom provider
*/
healthCheck(): Promise<AuthHealthCheck>;
}