UNPKG

@mastra/core

Version:

Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.

32 lines 1.26 kB
import type { HonoRequest } from 'hono'; import { MastraAuthProvider } from './auth.js'; import type { MastraAuthProviderOptions } from './auth.js'; export interface SimpleAuthOptions<TUser = unknown> extends MastraAuthProviderOptions<TUser> { /** * A map of tokens to users. * When a token is provided, it will be looked up in this map. */ tokens: Record<string, TUser>; /** * Headers to check for the token. * Defaults to 'Authorization' with Bearer token extraction. * Can be a string or array of strings for custom header names. */ headers?: string | string[]; } /** * SimpleAuth is a basic token-based authentication provider. * It validates tokens against a predefined map of tokens to users. */ export declare class SimpleAuth<TUser = unknown> extends MastraAuthProvider<TUser> { private tokens; private headerNames; private authenticatedUsers; constructor(options: SimpleAuthOptions<TUser>); private normalizeHeaders; private extractBearerToken; private findTokenInHeaders; authenticateToken(token: string, request: HonoRequest): Promise<TUser | null>; authorizeUser(user: TUser, _request: HonoRequest): Promise<boolean>; } //# sourceMappingURL=simple-auth.d.ts.map