()
| 373 | * Priority: remote > plist/hklm > file (managed-settings.json) > hkcu |
| 374 | */ |
| 375 | export function getPolicySettingsOrigin(): |
| 376 | | 'remote' |
| 377 | | 'plist' |
| 378 | | 'hklm' |
| 379 | | 'file' |
| 380 | | 'hkcu' |
| 381 | | null { |
| 382 | // 1. Remote (highest) |
| 383 | const remoteSettings = getRemoteManagedSettingsSyncFromCache() |
| 384 | if (remoteSettings && Object.keys(remoteSettings).length > 0) { |
| 385 | return 'remote' |
| 386 | } |
| 387 | |
| 388 | // 2. Admin-only MDM (HKLM / macOS plist) |
| 389 | const mdmResult = getMdmSettings() |
| 390 | if (Object.keys(mdmResult.settings).length > 0) { |
| 391 | return getPlatform() === 'macos' ? 'plist' : 'hklm' |
| 392 | } |
| 393 | |
| 394 | // 3. managed-settings.json + managed-settings.d/ (file-based, requires admin) |
| 395 | const { settings: fileSettings } = loadManagedFileSettings() |
| 396 | if (fileSettings) { |
| 397 | return 'file' |
| 398 | } |
| 399 | |
| 400 | // 4. HKCU (lowest — user-writable) |
| 401 | const hkcu = getHkcuSettings() |
| 402 | if (Object.keys(hkcu.settings).length > 0) { |
| 403 | return 'hkcu' |
| 404 | } |
| 405 | |
| 406 | return null |
| 407 | } |
| 408 | |
| 409 | /** |
| 410 | * Merges `settings` into the existing settings for `source` using lodash mergeWith. |
no test coverage detected