```ts
/** The KEY=VALUE pairs of a config file. */
export function parseConfig(text: string): Record<string, string> {
  const config: Record<string, string> = {};
  for (const line of text.split("\n")) {
    // Trim whitespace and remove comments
    const trimmedLine = line.trimStart().replace(/^#.*$/, '');
    
    if (!trimmedLine) continue; // Skip blank lines

    const [key, value] = trimmedLine.split('=', 2);
    if (key === '__proto__') {
      throw new Error(`Invalid config file line: ${line}. Key __proto__ is not allowed.`);
    }
    if (!key || !value) {
      throw new Error(`Invalid config file line: ${line}. Missing key or value.`);
    }

    config[key.trim()] = value.trim();
  }
  return config;
}
```