/** * Token Auth Adapter * * JWT/Bearer token authentication adapter. * Validates tokens via a configurable verifier function, * allowing integration with any auth provider. */ import type { StreamAuthResult, StreamChannel, TokenAuthAdapterConfig } from '@plyaz/types/core'; import { BaseAuthAdapter } from '../BaseAuthAdapter'; /** * TokenAuthAdapter - Bearer token authentication * * Features: * - Configurable token verification function * - Scope-based channel authorization * - Support for custom header names * * @example * ```ts * const authAdapter = new TokenAuthAdapter({ * name: 'jwt', * verifyToken: async (token) => { * const decoded = await verifyJWT(token); * return { * valid: !!decoded, * userId: decoded?.sub, * scopes: decoded?.scopes, * }; * }, * }); * * // Authenticate request * const result = await authAdapter.authenticate(request); * if (result.authenticated) { * console.log('User:', result.userId); * } * ``` */ export declare class TokenAuthAdapter extends BaseAuthAdapter { private readonly verifyToken; private readonly headerName; constructor(config: TokenAuthAdapterConfig); /** * Authenticate request using bearer token * * @param request - HTTP request with Authorization header * @returns Authentication result with user info if valid */ authenticate(request: Request): Promise; /** * Check if user can subscribe to a channel * * Rules: * - 'system' channel requires authentication * - If scopes provided, channel must match a scope prefix * - Otherwise, allow subscription * * @param userId - User ID (undefined for anonymous) * @param channel - Channel to subscribe * @param scopes - User's allowed scopes */ canSubscribe(userId: string | undefined, channel: StreamChannel, scopes?: string[]): boolean; } //# sourceMappingURL=TokenAuthAdapter.d.ts.map