32a5479086
Use OS machine identifiers (Windows MachineGuid, macOS IOPlatformUUID, Linux machine-id) hashed as deviceId so all accounts on one PC share one license slot. Keep legacy userData/device.id for migration and retire it on re-activation. Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
989 B
TypeScript
32 lines
989 B
TypeScript
import fs from 'node:fs';
|
|
|
|
import { resolveMachineFingerprint } from './machineFingerprint';
|
|
import { deviceIdPath } from './paths';
|
|
|
|
/** Старый per-user UUID из userData/device.id (до привязки к железу). */
|
|
export function readLegacyDeviceId(userData: string): string | null {
|
|
try {
|
|
const existing = fs.readFileSync(deviceIdPath(userData), 'utf8').trim();
|
|
if (existing.length >= 8) return existing;
|
|
} catch {
|
|
/* empty */
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export function clearLegacyDeviceId(userData: string): void {
|
|
try {
|
|
fs.unlinkSync(deviceIdPath(userData));
|
|
} catch {
|
|
/* empty */
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Идентификатор устройства для лицензии: отпечаток физической машины.
|
|
* Одинаков для всех пользователей ОС на одном ПК (Windows/macOS/Linux).
|
|
*/
|
|
export function getOrCreateDeviceId(_userData?: string): string {
|
|
return resolveMachineFingerprint();
|
|
}
|