Overview

Implement Two-Factor Authentication (2FA) with standard TOTP algorithms.

Features

  • TOTP generation/verification
  • QR code generation
  • Backup code support
  • Compatible with Google Authenticator

Installation

npx hanma add otp

Dependencies

otpauth, qrcode

Code

// Source code not available

Usage

import { generateSecret, verifyToken } from './utils/otp';

const { secret, uri } = generateSecret('user@example.com');

Dependencies

Frequently Asked Questions

How do I install OTP Utilities?
Run the following command: npx hanma add otp
What dependencies are required?
This snippet requires: otpauth, qrcode. Make sure to install them before using the snippet.
How do I use this snippet?
Copy the code and paste it into your project. The snippet will be saved to utils/otp.ts.
Can I customize this snippet?
Yes! All snippets are copy-paste code that you own. Feel free to modify them to fit your needs.
Does this work with other frameworks?
This snippet is designed for the specific framework. Check the other framework pages for equivalent implementations.