MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / resolveKimiCodeRuntimeAuth

Function resolveKimiCodeRuntimeAuth

packages/oauth/src/managed-kimi-code.ts:348–368  ·  view source on GitHub ↗
(options: {
  readonly configuredBaseUrl?: string | undefined;
  readonly configuredOAuthRef?: ManagedKimiOAuthRefInput | undefined;
  readonly env?: ManagedKimiEnv | undefined;
})

Source from the content-addressed store, hash-verified

346}
347
348export function resolveKimiCodeRuntimeAuth(options: {
349 readonly configuredBaseUrl?: string | undefined;
350 readonly configuredOAuthRef?: ManagedKimiOAuthRefInput | undefined;
351 readonly env?: ManagedKimiEnv | undefined;
352}): ManagedKimiRuntimeAuth {
353 const env = options.env ?? process.env;
354 const envBaseUrl = kimiCodeEnvBaseUrl(env);
355 const envOAuthHost = kimiCodeEnvOAuthHost(env);
356 const hasEnvOverride = envBaseUrl !== undefined || envOAuthHost !== undefined;
357 const baseUrl =
358 envBaseUrl !== undefined ? normalizeBaseUrl(envBaseUrl) : options.configuredBaseUrl;
359 const expected = resolveKimiCodeOAuthRef({
360 oauthHost: hasEnvOverride ? envOAuthHost : options.configuredOAuthRef?.oauthHost,
361 baseUrl,
362 });
363 const configured = configuredOAuthRef(options.configuredOAuthRef);
364 if (configured === undefined) return { baseUrl, oauthRef: expected };
365 if (hasEnvOverride) return { baseUrl, oauthRef: expected };
366 if (configured.key !== expected.key) return { baseUrl, oauthRef: expected };
367 return { baseUrl, oauthRef: configured };
368}
369
370export function resolveKimiCodeLoginAuth(options: {
371 readonly configuredBaseUrl?: string | undefined;

Callers 6

refreshProviderModelsFunction · 0.90
runtimeOAuthRefMethod · 0.85
runtimeOAuthRefMethod · 0.85

Calls 5

kimiCodeEnvBaseUrlFunction · 0.85
kimiCodeEnvOAuthHostFunction · 0.85
normalizeBaseUrlFunction · 0.85
resolveKimiCodeOAuthRefFunction · 0.85
configuredOAuthRefFunction · 0.85

Tested by

no test coverage detected