()
| 458 | * Priority: remote > plist/hklm > file (managed-settings.json) > hkcu |
| 459 | */ |
| 460 | export function getPolicySettingsOrigin(): |
| 461 | | 'remote' |
| 462 | | 'plist' |
| 463 | | 'hklm' |
| 464 | | 'file' |
| 465 | | 'hkcu' |
| 466 | | null { |
| 467 | // 1. Remote (highest) |
| 468 | const remoteSettings = getRemoteManagedSettingsSyncFromCache() |
| 469 | if (remoteSettings && Object.keys(remoteSettings).length > 0) { |
| 470 | return 'remote' |
| 471 | } |
| 472 | |
| 473 | // 2. Admin-only MDM (HKLM / macOS plist) |
| 474 | const mdmResult = getMdmSettings() |
| 475 | if (Object.keys(mdmResult.settings).length > 0) { |
| 476 | return getPlatform() === 'macos' ? 'plist' : 'hklm' |
| 477 | } |
| 478 | |
| 479 | // 3. managed-settings.json + managed-settings.d/ (file-based, requires admin) |
| 480 | const { settings: fileSettings } = loadManagedFileSettings() |
| 481 | if (fileSettings) { |
| 482 | return 'file' |
| 483 | } |
| 484 | |
| 485 | // 4. HKCU (lowest — user-writable) |
| 486 | const hkcu = getHkcuSettings() |
| 487 | if (Object.keys(hkcu.settings).length > 0) { |
| 488 | return 'hkcu' |
| 489 | } |
| 490 | |
| 491 | return null |
| 492 | } |
| 493 | |
| 494 | /** |
| 495 | * Merges `settings` into the existing settings for `source` using lodash mergeWith. |
no test coverage detected