About Alfred:Read the authentication code in your recent messages

Nowadays, many services have a 2FA mechanism, requiring SMS verification for login or online payments. Upon receiving the SMS, users need to input the verification code.

The iPhone supports automatic extraction, and you can fill in the code with just a tap. However, on the Mac, only Safari offers a similar experience. If you use Chrome or other apps, you lose this convenience. To address this shortcoming, a workflow was developed to enhance the experience.

Download link: Click here

Screenshot

As shown above, after receiving the message, wait a few seconds. Once the SMS is received, type 2fa to invoke the workflow, select the verification code item, and press Enter to copy it to the clipboard. Use ⌘ + v to paste it into the target input field.

Note

  1. Different verification codes have varying validity periods. Therefore, the workflow allows the validity period to be set with a default search for SMS verification codes received within the last 10 minutes.
  2. To ensure reading SMS on the Mac, Alfred needs disk access permissions.

Principle

  1. You can set up your iPhone to forward all received SMS, including iMessage, to the Mac, ensuring that the Mac can receive verification code SMS.
  2. The SMS messages on the Mac are stored in /Library/Messages/chat.db. Alfred needs to be granted permission to read this database file to retrieve the SMS information.
  3. Regular expressions are used to extract the verification code.

At the end

After setting up, it should be more convenient.