How tasselx/keyden works
Purpose and Runtime
Keyden is a native macOS 12+ menu-bar TOTP authenticator, written in Swift 5.9 with SwiftUI and AppKit. It operates offline-first, generating codes locally and retaining secrets in macOS Keychain. The Xcode project builds both the GUI app and a bundled command-line client: Keyden.xcodeproj/project.pbxproj, Keyden/KeydenApp.swift, KeydenCLI/main.swift.
Application Bootstrap and Menu-Bar Shell
The SwiftUI app entry point initializes the app lifecycle; AppKit integration owns menu-bar behavior and likely popup/window coordination. The primary interactive surface is the menu-bar token list rather than a conventional browser or server application.
• Keyden/KeydenApp.swift
• Keyden/App/AppDelegate.swift
• Keyden/App/MenuBarController.swift
• Keyden/Views/MenuBarContentView.swift
Token Domain and Secure Vault Boundary
Token is the central account representation, carrying TOTP identity/configuration used by UI, generation, persistence, sync, import/export, and CLI. VaultService coordinates the local token store, while KeychainService is the security boundary for encrypted secret persistence through macOS Keychain Services. Secrets should not need to cross this boundary except for explicit backup/sync/import workflows.
• Keyden/Models/Token.swift
• Keyden/Services/VaultService.swift
• Keyden/Services/KeychainService.swift
TOTP Generation and Time Flow
TOTP computation is isolated from presentation and backed by CryptoKit. A timer service drives periodic refreshes so menu-bar and management views display current codes and validity windows. UI copy actions consume generated codes, while the CLI uses the same token/generation domain.
• Keyden/Services/TOTPService.swift
• Keyden/Services/TOTPTimerService.swift
• Keyden/Views/MenuBarContentView.swift
Token Acquisition, Export, and Management
The management UI supports manual token creation, batch import, ordering/pinning, grouping, and deletion. QR handling forms the visual interchange boundary for standard OTP URIs and token QR export; Google Authenticator migration parsing is a separate import path for its migration QR/link format.
• Keyden/Views/AddTokenView.swift
• Keyden/Views/ManagementView.swift
• Keyden/Services/QRCodeService.swift
• Keyden/Services/GoogleAuthMigrationService.swift
Optional Integrations and System Services
GitHub Gist sync is an opt-in remote boundary using a user-provided GitHub personal access token and private Gists; local encrypted storage remains the primary source of operation. Global shortcut registration is handled separately. Appearance, update behavior, and user choices are centralized through settings-oriented services/UI.
• Keyden/Services/GistSyncService.swift
• Keyden/Services/HotkeyService.swift
• Keyden/Services/ThemeManager.swift
• Keyden/Services/UpdateService.swift
• Keyden/Views/SettingsView.swift
CLI and Distribution
keyden provides automation commands to get, list, and search accounts, and is bundled inside the macOS app for installation by users. GUI and CLI require compatible access to the vault/Keychain data, governed by separate entitlement files. Builds target Apple Silicon, Intel, or universal artifacts and package a DMG; GitHub Actions handles release/version automation.
• KeydenCLI/main.swift
• Keyden/Services/CLIService.swift
• Keyden/Keyden.entitlements
• KeydenCLI/KeydenCLI.entitlements
• Makefile
• .github/workflows/release.yml
Main entry points: VaultService.swift Vault Service · MenuBarContentView.swift Menu Bar Content · CLIService.swift CLI Service · MenuBarController.swift Menu Bar Controller
Components 20
macOS App
Menu-bar runtime and management surfaces.
- SwiftUI App Entry
Keyden/KeydenApp.swift - App Delegate
Keyden/App/AppDelegate.swift - Menu Bar Controller
Keyden/App/MenuBarController.swift - Menu Bar Content · Primary interactive token list and code-copy surface.
Keyden/Views/MenuBarContentView.swift - Management UI · Creates, organizes, pins, groups, and deletes tokens.
Keyden/Views/ManagementView.swift - Add Token UI
Keyden/Views/AddTokenView.swift - Settings UI
Keyden/Views/SettingsView.swift
Core Vault & Codes
Shared token, secure storage, and TOTP flow.
- Token · Shared TOTP account identity and configuration.
Keyden/Models/Token.swift - Vault Service · Coordinates the local token store.
Keyden/Services/VaultService.swift - Keychain Service · macOS Keychain boundary for secret persistence.
Keyden/Services/KeychainService.swift - TOTP Service · CryptoKit-backed local TOTP computation.
Keyden/Services/TOTPService.swift - TOTP Timer Service
Keyden/Services/TOTPTimerService.swift
Import, Sync & System
Optional external and macOS integrations.
- QR Code Service · Imports standard OTP URIs and exports token QR codes.
Keyden/Services/QRCodeService.swift - Google Migration Service · Parses Google Authenticator migration QR/link data.
Keyden/Services/GoogleAuthMigrationService.swift - Gist Sync Service · Uses private GitHub Gists with a user-provided token.
Keyden/Services/GistSyncService.swift - Hotkey Service
Keyden/Services/HotkeyService.swift - Theme & Update Services · Centralizes appearance and update behavior.
Keyden/Services/ThemeManager.swift
CLI & Delivery
Automation client and release packaging.
- keyden CLI · Gets, lists, and searches accounts using the shared vault domain.
KeydenCLI/main.swift - CLI Service
Keyden/Services/CLIService.swift - Build & Release · Builds app and bundled CLI, packages DMGs, and automates releases.
Makefile
Connections 22
- SwiftUI App Entry → App Delegate: starts
- App Delegate → Menu Bar Controller: owns
- Menu Bar Controller → Menu Bar Content: presents
- Menu Bar Content → Vault Service: loads tokens
- Management UI → Vault Service: manages
- Add Token UI → QR Code Service: scans/imports
- Add Token UI → Google Migration Service: imports migrations
- QR Code Service → Vault Service: creates tokens
- Google Migration Service → Vault Service: creates tokens
- Vault Service → Token: stores
- Vault Service → Keychain Service: persists secrets
- Menu Bar Content → TOTP Service: displays codes
- TOTP Service → Token: computes from
- TOTP Timer Service → Menu Bar Content: refreshes
- Gist Sync Service → Vault Service: backs up/syncs · Explicit optional interchange flow.
- Settings UI → Theme & Update Services: configures
- Hotkey Service → Menu Bar Controller: activates
- keyden CLI → CLI Service: runs commands
- CLI Service → Vault Service: reads accounts
- CLI Service → TOTP Service: generates codes
- Build & Release → SwiftUI App Entry: builds app
- Build & Release → keyden CLI: bundles CLI