Skip to content

Cococolins/OTPilot

Repository files navigation

OTPilot

中文 | English

OTPilot is a macOS 13+ menu bar utility for SMS one-time passwords. It watches the local Messages database, extracts likely verification codes, copies the code to the clipboard, and can optionally paste it into the currently focused field.

It is designed for browsers like Dia, Chrome, and Arc where macOS does not provide Safari-style SMS code autofill.

Features

  • Menu bar app, no Dock icon.
  • Reads incoming SMS/iMessage rows from ~/Library/Messages/chat.db.
  • Extracts common English and Chinese OTP formats.
  • Copies detected codes to the clipboard.
  • Optional auto paste using Command-V.
  • Optional clipboard restore after 45 seconds.
  • Notification feedback when a code is copied and still needs to be pasted.
  • Optional launch at login.
  • Starts monitoring automatically when the app opens by default.

Requirements

OTPilot is distributed as a downloadable DMG and as source code. The DMG is not notarized yet, so the first launch may require right-clicking the app and choosing Open, or approving it in System Settings.

  • macOS 13 or later.
  • Messages configured on the Mac and SMS forwarding/iMessage sync enabled.
  • Full Disk Access permission for OTPilot.
  • Accessibility permission if Auto paste is enabled.
  • For the DMG: Apple Silicon and Intel Macs are both supported; no Xcode or Command Line Tools are required.
  • For source builds: macOS 13 SDK or later, plus Xcode or Apple Command Line Tools with swift, make, codesign, and standard macOS developer tools available.
  • Optional for source builds: a local Apple Development signing identity. A free Apple ID development certificate is enough for local use; a paid Developer ID certificate is only needed for polished public distribution/notarization.

Check your local toolchain with:

swift --version
security find-identity -v -p codesigning

Install And Run

For Non-Technical Users

The recommended install path is the DMG. It contains a prebuilt app, so you do not need Xcode, Swift, or Terminal.

  1. Open the latest release.
  2. Download OTPilot-v1.5.1.dmg.
  3. Open the DMG.
  4. Drag OTPilot.app to the Applications shortcut.
  5. Open OTPilot from /Applications.

Because this build is not notarized yet, macOS may block the first launch. If that happens, right-click OTPilot.app, choose Open, then confirm. On some macOS versions you may need to open System Settings -> Privacy & Security and click Open Anyway.

After the app opens, grant Full Disk Access. Grant Accessibility only if you want Auto paste.

If you prefer to build from source instead, download the source ZIP from the release, unzip it, and double-click Install OTPilot.command. That path requires Apple's Command Line Tools:

xcode-select --install

macOS will show an installation prompt. Follow the prompt, then double-click Install OTPilot.command again.

For Terminal Users

Run the install command from the project folder. For example, after cloning the repository:

git clone https://github.com/Cococolins/OTPilot.git
cd OTPilot
make install

If you downloaded the source as a ZIP, unzip it, open Terminal, cd into the unzipped OTPilot folder, then run:

make install

This builds the SwiftPM app, stages dist/OTPilot.app, signs it, copies it to /Applications/OTPilot.app, and launches the installed app.

You can also call the underlying script directly:

./script/build_and_run.sh --install

Use --install during development too. macOS privacy permissions are tied to app identity and path, so switching between dist/OTPilot.app and /Applications/OTPilot.app can make Accessibility or Full Disk Access look enabled while the running app is not actually trusted.

Permissions

OTPilot needs Full Disk Access to read:

~/Library/Messages/chat.db

Auto paste requires Accessibility permission. OTPilot uses the Accessibility API to check whether the currently focused UI element is an editable text field. If it is, OTPilot sends Command-V so browser paste handlers, including multi-box OTP fields, can still do their own splitting. If no editable field is focused, OTPilot leaves the code on the clipboard and shows a notification instead of blindly sending Command-V.

If auto paste does not work, check:

log show --last 5m --predicate 'subsystem == "app.otpilot.OTPilot"' --style compact

Expected auto-paste logs look like:

Detected OTP ... autoPaste=true; accessibilityTrusted=true
Posted Command-V event

Posted Command-V event means the keyboard event was sent after OTPilot found a focused editable field. macOS still does not report whether the target app actually accepted the paste.

If the log says Accessibility is not trusted, remove any old OTPilot entry from System Settings, add /Applications/OTPilot.app again, and enable it.

Notifications intentionally do not include the OTP or sender. OTPilot shows a notification when it copies a code and cannot find a focused editable field. When it sends Command-V into a focused field, it does not show a notification because the paste action itself is the feedback.

Signing

The build script prefers a local Apple Development signing identity if one exists, and falls back to ad-hoc signing only when no identity is available.

Stable signing helps macOS keep Full Disk Access, Accessibility, and Login Items permissions across app updates.

Ad-hoc signed local builds can run, but macOS may treat frequent rebuilds as a changed app identity. If permissions appear to reset after every build, use a stable Apple Development certificate and keep installing to /Applications/OTPilot.app.

For public GitHub releases, a Developer ID signed and notarized build would provide the cleanest first-launch experience. Without notarization, users may need to right-click Open or approve the app in Privacy & Security the first time.

To override signing:

SIGN_IDENTITY="Apple Development: Your Name (TEAMID)" ./script/build_and_run.sh --install

To override the bundle identifier for your own builds:

BUNDLE_ID="com.example.OTPilot" ./script/build_and_run.sh --install

OTP Parsing

The parser is optimized for both English and Chinese SMS templates. It does not assume the code always appears after the keyword.

Supported examples include:

【豆瓣网】豆瓣登录验证码:2463
【哔哩哔哩】597700短信登录验证码
[瑞幸咖啡] 验证码:088864
Use 837201 as your login code.
G-789012 is your Google verification code

The current strategy is:

  1. Find verification keywords, including simplified/traditional Chinese variants.
  2. Enumerate 4-8 character candidates near the keyword.
  3. Filter likely date/time and URL tokens.
  4. Rank 6-digit numeric codes first, then 4-digit, other numeric, and alphanumeric codes.

Useful Commands

Build only:

make build

Build the app bundle:

make app

Build a distributable DMG:

make dmg

The DMG build creates a universal app by default, with both arm64 and x86_64 slices. To build a single-architecture DMG for local testing:

BUILD_ARCHS=arm64 make dmg

Install and launch:

make install

Verify process launch:

make verify

Stream app logs:

make telemetry

Inspect the running app path:

ps -axo pid,comm,args | rg 'OTPilot' | rg -v rg

Inspect code signature:

codesign -dv --verbose=4 /Applications/OTPilot.app 2>&1 | sed -n '1,90p'

Prior Art

  • OTeePee: macOS 15+ menu bar app that reads ~/Library/Messages/chat.db, detects OTP patterns, and copies codes to the clipboard.
  • imsg: robust Messages database reader and watcher. Useful for understanding chat.db, filesystem events, and Full Disk Access behavior.
  • Faktor: browser-oriented OTP autofill system pairing a macOS app with a Chrome extension.
  • XposedSmsCode, smscode-core, and smscode-rules: useful references for Chinese SMS-code parsing rules.

License

OTPilot is released under the MIT License.

Notes

OTPilot starts from the newest Messages row on first launch, so it does not scan old SMS history. Use Reset to clear the current detection state and reset the cursor to the latest message.

Auto paste is still focus-dependent: the target input field must be focused when the SMS arrives. OTPilot can now avoid sending Command-V when the focused UI element is clearly not editable, but it cannot choose the right field on a page by itself.

About

macOS menu bar utility for SMS one-time passwords

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors