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

Function fetchLatestVersionFromCdn

apps/kimi-code/src/cli/update/cdn.ts:58–70  ·  view source on GitHub ↗
(
  fetchImpl: typeof fetch = fetch,
)

Source from the content-addressed store, hash-verified

56 * `fetchImpl` is injectable for tests; defaults to the global `fetch`.
57 */
58export async function fetchLatestVersionFromCdn(
59 fetchImpl: typeof fetch = fetch,
60): Promise<string> {
61 const response = await fetchWithTimeout(fetchImpl, KIMI_CODE_CDN_LATEST_URL);
62 if (!response.ok) {
63 throw new Error(`CDN /latest returned HTTP ${response.status}`);
64 }
65 const raw = (await response.text()).trim();
66 if (valid(raw) === null) {
67 throw new Error(`CDN /latest returned invalid semver: ${JSON.stringify(raw)}`);
68 }
69 return raw;
70}
71
72async function fetchUpdateManifestFromCdn(fetchImpl: typeof fetch): Promise<UpdateManifest> {
73 const response = await fetchWithTimeout(fetchImpl, KIMI_CODE_CDN_LATEST_JSON_URL);

Callers 2

cdn.test.tsFile · 0.90
fetchLatestFromCdnFunction · 0.85

Calls 2

fetchWithTimeoutFunction · 0.70
textMethod · 0.65

Tested by

no test coverage detected