Skip to content

feat: add experimental system-wide API key masking via Accessibility overlay#10

Merged
easyvibecoding merged 2 commits intomainfrom
feat/system-wide-masking
Mar 21, 2026
Merged

feat: add experimental system-wide API key masking via Accessibility overlay#10
easyvibecoding merged 2 commits intomainfrom
feat/system-wide-masking

Conversation

@easyvibecoding
Copy link
Copy Markdown
Owner

Summary

  • 🧪 Experimental: System-wide API key masking using macOS Accessibility API
  • AXObserver monitors focused UI elements across all apps, detects API keys via MaskingCoordinator
  • AXBoundsForRange for precise multi-line text coordinates
  • Click-through NSPanel overlays (ignoresMouseEvents), reuses panels via deterministic UUID
  • Settings toggle in Security tab (default OFF), activates as Demo Mode enhancement only
  • Peek mode: hold ⌃⌥Space to temporarily reveal masked content
  • Performance: 2-6ms total processing, 10ms initial / 30ms debounce, immediate scan on app switch
  • Contributor guide: ScreenCaptureKit + Virtual Camera roadmap for more secure approach

Known Limitations

  • Only scans focused element (sidebar/non-focused areas not covered)
  • Copy/paste still exposes original key (visual overlay only)
  • Some apps may not fully support AX text attributes

Test plan

  • swift build + swift test — 48 tests pass
  • Manual: TextEdit — key fully covered across 3 lines
  • Manual: Notes — 4 keys independently overlaid
  • Manual: App switch — immediate overlay on return (~10ms)
  • Manual: Fast editing — overlay tracks within ~30ms
  • Manual: Settings toggle ON/OFF — immediate effect
  • Manual: Demo Mode OFF — all overlays removed
  • IO safety review: safe AX casts, NSHostingView reuse, callback guard

🤖 Generated with Claude Code

easyvibecoding and others added 2 commits March 22, 2026 03:32
…overlay

Add system-wide masking that detects API keys in any macOS application
using the Accessibility API and covers them with floating NSPanel overlays.

Core implementation:
- SystemMaskingService: AXObserver monitors focused UI elements across
  all apps via kAXFocusedUIElementChangedNotification and
  kAXValueChangedNotification. 10ms initial / 30ms debounce + 500ms
  polling fallback. Immediate scan on app switch.
- AXBoundsForRange: precise multi-line text coordinate calculation,
  supports keys spanning multiple visual lines
- SystemOverlayController: click-through NSPanel overlays with
  ignoresMouseEvents, reuses panels via deterministic UUID per match
- MaskOverlayView: solid background overlay with masked text display

Integration:
- Settings toggle: "System-wide masking (experimental)" in Security tab,
  default OFF. Only activates when both setting AND Demo Mode are ON.
- Peek mode: hold ⌃⌥Space to temporarily hide all overlays
- Overlay lifecycle: auto-clear on app switch, text change, Demo Mode OFF

Performance (measured):
- Pattern matching: 0.1-0.3ms per scan
- Total scan + overlay: 2-6ms
- NSHostingView reuse prevents view accumulation
- Text cache prevents redundant overlay updates
- Safe AX API usage: nil guards, isRunning check in callback

Known limitations (marked experimental):
- Only scans focused element (sidebar/non-focused areas not covered)
- Copy/paste still exposes original key (visual overlay only)
- Some apps may not fully support AX text attributes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Document ScreenCaptureKit + Virtual Camera approach as a more secure
alternative to the overlay method. Includes architecture, code examples,
lessons learned from overlay implementation, and suggested contribution order.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@easyvibecoding easyvibecoding merged commit ec4cf37 into main Mar 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant