sandbox-settings.ts 997 B

12345678910111213141516171819202122232425
  1. /** Pure value model for sandbox settings, shared by config parsing and the renderer without Node.js dependencies. */
  2. export type SandboxFilesystemModeName =
  3. | 'read_only'
  4. | 'workspace_write'
  5. | 'delete_guard'
  6. | 'full_access';
  7. export interface SandboxSettingsSnapshot {
  8. enabled: boolean;
  9. filesystemMode: SandboxFilesystemModeName;
  10. }
  11. /** Default to full access with deletion protection off on every platform; retain the platform parameter for shared callers. */
  12. export function getDefaultSandboxSettings(_platform: string): SandboxSettingsSnapshot {
  13. return { enabled: false, filesystemMode: 'full_access' };
  14. }
  15. /** Normalize the legacy disabled master switch and full access to no sandbox; retain other enabled levels. */
  16. export function normalizeSandboxSettings(
  17. settings: SandboxSettingsSnapshot,
  18. ): SandboxSettingsSnapshot {
  19. return !settings.enabled || settings.filesystemMode === 'full_access'
  20. ? { enabled: false, filesystemMode: 'full_access' }
  21. : { ...settings };
  22. }