Skip to content

Commit da1bd52

Browse files
committed
fix(oauth): report sanitized host OS version to Kimi
1 parent af541ae commit da1bd52

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

packages/oauth/src/kimi-oauth.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { randomUUID } from 'node:crypto';
2+
import { release } from 'node:os';
23

34
import { runDeviceOAuthFlow, type DeviceCodeInfo } from './device-oauth';
45
import { capabilitiesForModel, fetchOpenPlatformModels } from './open-platform';
@@ -18,6 +19,10 @@ const TOKEN_URL = 'https://auth.kimi.com/api/oauth/token';
1819
export const KIMI_CODING_BASE_URL = 'https://api.kimi.com/coding/v1';
1920
const KIMI_SCOPE = 'kimi-code';
2021

22+
function sanitizeHeaderValue(value: string): string {
23+
return value.replace(/[^\x20-\x7e]/g, '').trim();
24+
}
25+
2126
/**
2227
* kimi-cli fingerprints every request (OAuth and inference) with these
2328
* headers. `X-Msh-Device-Id` must stay stable across the OAuth flow and
@@ -30,7 +35,7 @@ function kimiHeaders(deviceId: string): Record<string, string> {
3035
'X-Msh-Version': '1.0.0',
3136
'X-Msh-Device-Name': 'pythinker-code',
3237
'X-Msh-Device-Model': process.arch,
33-
'X-Msh-Os-Version': process.version,
38+
'X-Msh-Os-Version': sanitizeHeaderValue(release()),
3439
'X-Msh-Device-Id': deviceId,
3540
};
3641
}

0 commit comments

Comments
 (0)