first commit
This commit is contained in:
commit
ff482ebe23
251 files changed
+19126
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
// These names are shared by native IPC guards and the trusted browser chrome.
|
||||
// Hiding a section removes access, rather than only changing its presentation.
|
||||
export const SETTINGS_SECTIONS = Object.freeze(['appearance', 'library', 'ai', 'passwords', 'documentScan', 'agents']);
|
||||
const sections = z.array(z.enum(SETTINGS_SECTIONS)).max(SETTINGS_SECTIONS.length).refine(items => new Set(items).size === items.length, 'Settings sections must be unique');
|
||||
export const ManagedSettingsSchema = z.object({
|
||||
visible: z.boolean().default(true),
|
||||
hiddenSections: sections.default([]),
|
||||
lockedSections: sections.default([]),
|
||||
appearance: z.object({
|
||||
mode: z.enum(['system', 'light', 'dark']).default('system'),
|
||||
accent: z.enum(['blue', 'teal', 'violet']).default('blue'),
|
||||
tabMode: z.enum(['separate', 'compact']).default('separate')
|
||||
}).strict().prefault({})
|
||||
}).strict().prefault({});
|
||||
|
||||
export function settingsSectionAllowed(policy, section) {
|
||||
if (!SETTINGS_SECTIONS.includes(section)) return false;
|
||||
const settings = ManagedSettingsSchema.safeParse(policy?.browser?.settings);
|
||||
return settings.success && settings.data.visible && !settings.data.hiddenSections.includes(section) && !settings.data.lockedSections.includes(section);
|
||||
}
|
||||
Reference in new issue
Block a user