issa0522
v1.0.0
Published
TOTP (RFC 6238) / Google Authenticator compatible 2FA helper.
Maintainers
Readme
@ton-org/asafe2fa-js
Small TOTP (RFC 6238) helper compatible with Google Authenticator / Authy.
Install
npm i @ton-org/asafe2fa-jsUsage
import { Asafe2FA } from "@ton-org/asafe2fa-js";
const a2fa = new Asafe2FA();
const secret = a2fa.generateSecret(); // base32
const url = a2fa.getOtpAuthUrl("[email protected]", "MyCompany", secret);
const otp = a2fa.getCurrentOtp(secret);
const ok = a2fa.verifyKey(secret, otp, 1);API
Asafe2FA.generateSecret(length?: number): stringAsafe2FA.getOtpAuthUrl(account: string, issuer: string, secret: string): stringAsafe2FA.getCurrentOtp(secret: string, options?: TotpOptions): stringAsafe2FA.verifyKey(secret: string, token: string, window?: number, options?: TotpOptions): boolean
License
MIT
