import type { AuthStrategy, AuthSession, ResolvedAuth } from './types'; export class BearerTokenStrategy implements AuthStrategy { constructor(private getToken: (config: ResolvedAuth) => Promise) {} async authenticate(config: ResolvedAuth): Promise { const token = await this.getToken(config); return { headers: { Authorization: `Bearer ${token}` } }; } async restore(cached: AuthSession, _config: ResolvedAuth): Promise { if (cached.expiresAt && Date.now() > cached.expiresAt) return null; return cached; } async refresh(session: AuthSession, config: ResolvedAuth): Promise { return this.authenticate(config); } }