(options: {
readonly configuredBaseUrl?: string | undefined;
readonly configuredOAuthRef?: ManagedKimiOAuthRefInput | undefined;
readonly env?: ManagedKimiEnv | undefined;
})
| 346 | } |
| 347 | |
| 348 | export 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 | |
| 370 | export function resolveKimiCodeLoginAuth(options: { |
| 371 | readonly configuredBaseUrl?: string | undefined; |
no test coverage detected