2famsg
Retrieve 2FA codes from Apple Messages on MacOS as JSON output with CLI or API
Installation
npm install -g 2famsg || yarn global add 2famsg
CLI Usage
2famsg [-a | --alfred] [-d | --database DATABASE_PATH] [-q | --query QUERY_TERM]
Also available via npx
but loads much more slowly.
CLI Options
-
-a
or--alfred
[Boolean
]: Format output for Alfred -
-d
or--database
[String
]: Specify database path (Default:~/Library/Messages/chat.db
) -
-q
or--query
[String
]: Term by which to filter results (eg.,facebook
oramazon
)
Node Module Usage
const twoFactorMsg = require('2famsg')
const codes = async () =>
await twoFactorMsg({
query: 'facebook'
})
Module Options
-
alfred
[Boolean
]: Format output for Alfred -
database
[String
]: Specify database path (Default:~/Library/Messages/chat.db
) -
query
[String
]: Term by which to filter results (eg.,facebook
oramazon
)
Build Binaries
npm run build:sqlite
npm run build:bin
Author
- Website: self.agency
- Twitter: @selfagency_llc
- GitLab: @selfagency
Acknowledgements
The SQLite query was lifted from Scott Carpenter's alfred-imessage-2fa Alfred workflow, which I modified somewhat. Scott's project was a great start but I was looking for a more robust solution and decided to build one in a language in which I felt more comfortable jamming on the code.
Contributing
Contributions, issues and feature requests are welcome! Feel free to check issues page.
Show your support
Give a