// {{ display_name }} MCP server — generated by mcpify. Do not hand-edit.

import type { AuthConfig, AuthStrategy, Credentials } from '../auth-strategy.js';
import { MissingCredentialsError } from '../errors.js';

export class BasicAuthStrategy implements AuthStrategy {
  async authenticate(config: AuthConfig): Promise<Credentials> {
    const { username, password } = config;
    if (!username || !password) {
      throw new MissingCredentialsError(['username', 'password']);
    }
    const token = Buffer.from(`${username}:${password}`, 'utf8').toString('base64');
    return { username, password, authorizationHeader: `Basic ${token}` };
  }

  validateCredentials(credentials: Credentials): boolean {
    return typeof credentials.authorizationHeader === 'string';
  }
}
