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

Function createKimiDeviceId

packages/oauth/src/identity.ts:46–68  ·  view source on GitHub ↗
(
  homeDir: string,
  options: CreateKimiDeviceIdOptions = {},
)

Source from the content-addressed store, hash-verified

44}
45
46export function createKimiDeviceId(
47 homeDir: string,
48 options: CreateKimiDeviceIdOptions = {},
49): string {
50 const existing = readKimiDeviceId(homeDir);
51 if (existing !== null) return existing;
52
53 const id = randomUUID();
54 try {
55 mkdirSync(homeDir, { recursive: true, mode: 0o700 });
56 writeFileSync(join(homeDir, 'device_id'), id, { encoding: 'utf-8', mode: 0o600 });
57 } catch {
58 // Best-effort: requests can still use the in-memory id.
59 }
60 if (options.onFirstLaunch !== undefined) {
61 try {
62 options.onFirstLaunch(id);
63 } catch {
64 // Telemetry callback must not affect device id creation.
65 }
66 }
67 return id;
68}
69
70export function createKimiDeviceHeaders(options: {
71 readonly homeDir: string;

Callers 3

identity.test.tsFile · 0.90
createKimiDeviceHeadersFunction · 0.85

Calls 1

readKimiDeviceIdFunction · 0.85

Tested by

no test coverage detected