MCPcopy
hub / github.com/MiniMax-AI/cli / parseOAuth

Function parseOAuth

src/config/schema.ts:46–61  ·  view source on GitHub ↗
(raw: unknown)

Source from the content-addressed store, hash-verified

44const VALID_OUTPUTS = new Set<string>(['text', 'json']);
45
46function parseOAuth(raw: unknown): OAuthCredentials | undefined {
47 if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return undefined;
48 const o = raw as Record<string, unknown>;
49 if (typeof o.access_token !== 'string' || !o.access_token) return undefined;
50 if (typeof o.refresh_token !== 'string') return undefined;
51 if (typeof o.expires_at !== 'string') return undefined;
52 const out: OAuthCredentials = {
53 access_token: o.access_token,
54 refresh_token: o.refresh_token,
55 expires_at: o.expires_at,
56 };
57 if (typeof o.region === 'string' && VALID_REGIONS.has(o.region)) out.region = o.region as Region;
58 if (typeof o.resource_url === 'string' && o.resource_url.startsWith('http')) out.resource_url = o.resource_url;
59 if (typeof o.account === 'string' && o.account.length > 0) out.account = o.account;
60 return out;
61}
62
63export function parseConfigFile(raw: unknown): ConfigFile {
64 if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return {};

Callers 1

parseConfigFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected