TOTP (RFC 6238) / Google Authenticator compatible 2FA helper.
npm install issa0522Small TOTP (RFC 6238) helper compatible with Google Authenticator / Authy.
``bash`
npm i @ton-org/asafe2fa-js
`ts
import { Asafe2FA } from "@ton-org/asafe2fa-js";
const a2fa = new Asafe2FA();
const secret = a2fa.generateSecret(); // base32
const url = a2fa.getOtpAuthUrl("alice@example.com", "MyCompany", secret);
const otp = a2fa.getCurrentOtp(secret);
const ok = a2fa.verifyKey(secret, otp, 1);
`
- Asafe2FA.generateSecret(length?: number): stringAsafe2FA.getOtpAuthUrl(account: string, issuer: string, secret: string): string
- Asafe2FA.getCurrentOtp(secret: string, options?: TotpOptions): string
- Asafe2FA.verifyKey(secret: string, token: string, window?: number, options?: TotpOptions): boolean`
-
MIT