MCPcopy Create free account
hub / github.com/anus-dev/ANUS / validateAuthMethod

Function validateAuthMethod

packages/cli/src/config/auth.ts:11–35  ·  view source on GitHub ↗
(
  authMethod: string,
  settings?: LoadedSettings,
)

Source from the content-addressed store, hash-verified

9import { loadEnvironment, LoadedSettings } from './settings.js';
10
11export const validateAuthMethod = (
12 authMethod: string,
13 settings?: LoadedSettings,
14): string | null => {
15 loadEnvironment();
16
17 if (authMethod === AuthType.USE_GROK) {
18 // Check both environment variable and settings
19 const hasEnvKey =
20 !!process.env['GROK_API_KEY'] || !!process.env['XAI_API_KEY'];
21 const hasSettingsKey = !!settings?.merged.grok?.apiKey;
22
23 // If we have a settings key, ensure it gets exported to environment
24 if (hasSettingsKey && !hasEnvKey) {
25 process.env['GROK_API_KEY'] = settings!.merged.grok!.apiKey;
26 }
27
28 if (!hasEnvKey && !hasSettingsKey) {
29 return 'OpenRouter API key not found. Please set your GROK_API_KEY environment variable or configure it in settings. Get your API key from https://openrouter.ai/keys';
30 }
31 return null;
32 }
33
34 return 'Invalid auth method selected.';
35};

Callers 3

mainFunction · 0.85
AppFunction · 0.85
auth.test.tsFile · 0.85

Calls 1

loadEnvironmentFunction · 0.85

Tested by

no test coverage detected