tcc

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package tcc provides TCC (Transparency, Consent, Control) permission utilities.

Index

Constants

View Source
const (
	Camera          = permissions.Camera          // Camera access (com.apple.security.device.camera)
	Microphone      = permissions.Microphone      // Microphone access (com.apple.security.device.audio-input)
	Location        = permissions.Location        // Location services (com.apple.security.personal-information.location)
	ScreenRecording = permissions.ScreenRecording // Screen recording/capture (requires TCC approval)
	Accessibility   = permissions.Accessibility   // Accessibility (simulating input, etc.)
	Files           = permissions.Files           // File system access with user selection
	Network         = permissions.Network         // Network client/server access
	Sandbox         = permissions.Sandbox         // App sandbox with restricted file access
)

Core permissions covering 95% of use cases.

Variables

This section is empty.

Functions

func GetEntitlements

func GetEntitlements(perms []Permission) []string

GetEntitlements returns the entitlement strings for the given permissions.

func GetTCCServices

func GetTCCServices(perms []Permission) []string

GetTCCServices returns the TCC service names for permissions that support tccutil reset.

func HandleEdgeCase

func HandleEdgeCase(service, bundleID, appName string, debug bool) error

HandleEdgeCase provides user-friendly guidance for TCC permission edge cases. It analyzes the situation and provides clear recovery instructions.

func OpenSystemSettingsToTCC

func OpenSystemSettingsToTCC(service, bundleID, appName string, debug bool) error

OpenSystemSettingsToTCC opens System Settings to the appropriate TCC panel for the service. Returns an error with recovery instructions if edge cases are detected.

func RequiresTCC

func RequiresTCC(perms []Permission) bool

RequiresTCC returns true if any of the permissions require TCC prompts.

func Reset

func Reset(bundleID string, debug bool) error

Reset resets TCC permissions for the given bundle ID.

func ResetForPermissions

func ResetForPermissions(bundleID string, perms []Permission, debug bool) error

ResetForPermissions resets TCC permissions for the specific permissions provided.

func ResetSpecificServices

func ResetSpecificServices(bundleID string, services []string, debug bool) error

ResetSpecificServices resets only specific TCC services for a bundle ID.

func ResetWithConfig

func ResetWithConfig(cfg ResolutionConfig) error

ResetWithConfig resets TCC permissions using the provided configuration. It will resolve the bundle ID if not provided in the config.

func ResolveBundleID

func ResolveBundleID(cfg ResolutionConfig) (string, error)

ResolveBundleID resolves the bundle ID from the configuration. If BundleID is provided in config, it uses that. Otherwise, it infers one from the AppName or executable name.

func ValidateAppGroups

func ValidateAppGroups(groups []string, perms []Permission) error

ValidateAppGroups checks if app groups configuration is valid. App groups require sandbox permission to be enabled.

func ValidatePermissions

func ValidatePermissions(perms []Permission) error

ValidatePermissions checks if the provided permissions are valid and compatible.

func WaitForPermissionGrant

func WaitForPermissionGrant(service, bundleID string, timeout time.Duration, debug bool) (bool, error)

WaitForPermissionGrant waits for the user to grant permission in System Settings. Returns true if permission was granted, false if timeout or denied.

Types

type EdgeCaseError

type EdgeCaseError struct {
	Type     EdgeCaseType
	Message  string
	Service  string
	BundleID string
	Recovery string // Recovery instructions for the user
}

EdgeCaseError represents a TCC permission edge case that requires special handling.

func DetectEdgeCase

func DetectEdgeCase(service, bundleID string) (*EdgeCaseError, error)

DetectEdgeCase attempts to detect common TCC permission edge cases. It checks System Settings state and provides appropriate recovery instructions.

func (*EdgeCaseError) Error

func (e *EdgeCaseError) Error() string

type EdgeCaseType

type EdgeCaseType int

EdgeCaseType represents different types of TCC permission edge cases.

const (
	// EdgeCaseUnknown represents an unknown edge case
	EdgeCaseUnknown EdgeCaseType = iota

	// EdgeCasePromptDismissed indicates the user dismissed the TCC prompt
	EdgeCasePromptDismissed

	// EdgeCasePermissionDenied indicates the user explicitly denied permission
	EdgeCasePermissionDenied

	// EdgeCaseMultipleDenials indicates permission was denied multiple times
	EdgeCaseMultipleDenials

	// EdgeCaseSettingsOpen indicates System Settings is already showing the TCC panel
	EdgeCaseSettingsOpen

	// EdgeCaseSettingsLocked indicates the TCC panel is locked (requires authentication)
	EdgeCaseSettingsLocked

	// EdgeCaseAppNotInList indicates the app isn't shown in System Settings TCC list
	EdgeCaseAppNotInList
)

func (EdgeCaseType) String

func (t EdgeCaseType) String() string

type Permission

type Permission = permissions.Permission

Permission represents a macOS system permission that can be requested. These correspond to TCC (Transparency, Consent, Control) permission types.

type ResolutionConfig

type ResolutionConfig struct {
	BundleID string
	AppName  string
	Debug    bool
}

ResolutionConfig holds configuration for resolving bundle IDs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL